Где я настраиваю log4j в тестовом классе JUnit?

В вашем

link.js

Link.belongsToMany(models.Overlay, {
  as: 'overlays',
  through: models.LinkOverlays,
  foreignKey: 'linkId',
  targetKey: 'id',
});

Link.belongsToMany(models.Tracker, {
  as: 'trackers',
  through: models.LinkTrackers,
  foreignKey: 'trackerId', // should be linkId
  targetKey: 'id',
});

связь с LinkOverlays осуществляется через linkId, а связь с LinkTrackers - через [ 114] должно быть linkId, а также

83
задан James McMahon 18 May 2009 в 16:21
поделиться

3 ответа

The LogManager class determines which log4j config to use in a static block which runs when the class is loaded. There are three options intended for end-users:

  1. If you specify log4j.defaultInitOverride to false, it will not configure log4j at all.
  2. Specify the path to the configuration file manually yourself and override the classpath search. You can specify the location of the configuration file directly by using the following argument to java:

    -Dlog4j.configuration=

    in your test runner configuration.

  3. Allow log4j to scan the classpath for a log4j config file during your test. (the default)

See also the online documentation.

49
ответ дан 24 November 2019 в 08:55
поделиться

Обычно я просто помещаю файл log4j.xml в src / test / resources и позволяю log4j находить его самостоятельно: код не требуется, инициализация log4j по умолчанию подберет его. (Обычно я все равно хочу настроить свои собственные регистраторы на «DEBUG»)

58
ответ дан 24 November 2019 в 08:55
поделиться

Вы можете ознакомиться с Simple Logging Facade для Java (SLF4J) . Это фасад, который окружает Log4j и не требует вызова начальной настройки, такого как Log4j. Также довольно легко переключить Log4j на Slf4j, поскольку различия в API минимальны.

6
ответ дан 24 November 2019 в 08:55
поделиться
Другие вопросы по тегам:

Похожие вопросы: