Почему мои настройки log4j2 игнорируются?JAVA

Программисты JAVA общаются здесь
Anonymous
Почему мои настройки log4j2 игнорируются?

Сообщение Anonymous »

Файл log4j2.xml прост:

















Я знаю, что его читает Java-программа, потому что, если я внесу в него умышленную синтаксическую ошибку, программа пожалуется.
Но, когда это ясно, это игнорируется. Сообщения печатаются со стандартной ошибкой, но без префикса «Мяу» и без соответствующих временных меток. Каждая строка начинается с номера (в миллисекундах с начала?), потока ([main]) и уровень (INFO) вместо использования указанного шаблона:
1301 [main] INFO com.example.common.util.PFEAppUtil - Retreiving file contents
1303 [main] INFO com.example.common.util.PfeSmsDataUtils - Secrets from existing cache object ..

Что я делаю не так?
Обновление: запустив -Dlog4j2.debug, Я получил следующие дополнительные записи из StatusLogger, напечатанные перед первой записью журнала из нашего собственного кода. До сих пор не понимаю, почему мой шаблон игнорируется :(
DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
DEBUG StatusLogger Took 0,131474 seconds to load 255 plugins from jdk.internal.loader.ClassLoaders$AppClassLoader@137e0d2
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger AsyncLogger.ThreadNameStrategy=UNCACHED (user specified null, default is UNCACHED)
TRACE StatusLogger Using default SystemClock for timestamps.
DEBUG StatusLogger org.apache.logging.log4j.core.util.SystemClock supports precise timestamps.
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Converter' found 48 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG StatusLogger Starting LoggerContext[name=137e0d2, org.apache.logging.log4j.core.LoggerContext@cf93bb]...
DEBUG StatusLogger Reconfiguration started for context[name=137e0d2] at URI null (org.apache.logging.log4j.core.LoggerContext@cf93bb) with optional ClassLoader: null
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 6 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@15b7e8
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Closing FileInputStream java.io.FileInputStream@a41516
DEBUG StatusLogger Apache Log4j Core 2.20 initializing configuration XmlConfiguration[location=/mi/sftdbaas/src/main/resources/log4j2.xml]
DEBUG StatusLogger PluginManager 'Core' found 132 plugins
DEBUG StatusLogger PluginManager 'Level' found 0 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
TRACE StatusLogger TypeConverterRegistry initializing.
DEBUG StatusLogger PluginManager 'TypeConverter' found 26 plugins
DEBUG StatusLogger PatternLayout$Builder(pattern="Meow %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n", PatternSelector=null, Configuration(/mi/sftdbaas/src/main/resources/log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
DEBUG StatusLogger PluginManager 'Converter' found 48 plugins
DEBUG StatusLogger Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
DEBUG StatusLogger ConsoleAppender$Builder(target="SYSTEM_ERR", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(Meow %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n), name="stderr", Configuration(/mi/sftdbaas/src/main/resources/log4j2.xml), Filter=null, ={})
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_ERR.false.false
DEBUG StatusLogger Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
DEBUG StatusLogger createAppenders(={stderr})
DEBUG StatusLogger Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
DEBUG StatusLogger createAppenderRef(ref="stderr", level="null", Filter=null)
DEBUG StatusLogger Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
DEBUG StatusLogger LoggerConfig$RootLogger$Builder(additivity="null", level="INFO", levelAndRefs="null", includeLocation="null", ={stderr}, ={}, Configuration(/mi/sftdbaas/src/main/resources/log4j2.xml), Filter=null)
DEBUG StatusLogger Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
DEBUG StatusLogger createLoggers(={root})
DEBUG StatusLogger Configuration XmlConfiguration[location=/mi/sftdbaas/src/main/resources/log4j2.xml] initialized
DEBUG StatusLogger Starting configuration XmlConfiguration[location=/mi/sftdbaas/src/main/resources/log4j2.xml]
DEBUG StatusLogger Started configuration XmlConfiguration[location=/mi/sftdbaas/src/main/resources/log4j2.xml] OK.
TRACE StatusLogger Stopping org.apache.logging.log4j.core.config.DefaultConfiguration@b4fe2a...
TRACE StatusLogger DefaultConfiguration notified 1 ReliabilityStrategies that config will be stopped.
TRACE StatusLogger DefaultConfiguration stopping root LoggerConfig.
TRACE StatusLogger DefaultConfiguration notifying ReliabilityStrategies that appenders will be stopped.
TRACE StatusLogger DefaultConfiguration stopping remaining Appenders.
DEBUG StatusLogger Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG StatusLogger OutputStream closed
DEBUG StatusLogger Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
DEBUG StatusLogger Appender DefaultConsole-1 stopped with status true
TRACE StatusLogger DefaultConfiguration stopped 1 remaining Appenders.
TRACE StatusLogger DefaultConfiguration cleaning Appenders from 1 LoggerConfigs.
DEBUG StatusLogger Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@b4fe2a OK
TRACE StatusLogger Reregistering MBeans after reconfigure. Selector=org.apache.logging.log4j.core.selector.ClassLoaderContextSelector@1aa0fbd
TRACE StatusLogger Reregistering context (1/1): '137e0d2' org.apache.logging.log4j.core.LoggerContext@cf93bb
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=StatusLogger'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=ContextSelector'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=Loggers,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=Appenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=AsyncAppenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=AsyncLoggerRingBuffer'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=137e0d2,component=Loggers,name=*,subtype=RingBuffer'
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=137e0d2
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=137e0d2,component=StatusLogger
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=137e0d2,component=ContextSelector
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=137e0d2,component=Loggers,name=
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=137e0d2,component=Appenders,name=stderr
TRACE StatusLogger Using default SystemClock for timestamps.
DEBUG StatusLogger org.apache.logging.log4j.core.util.SystemClock supports precise timestamps.
TRACE StatusLogger Using DummyNanoClock for nanosecond timestamps.
DEBUG StatusLogger Reconfiguration complete for context[name=137e0d2] at URI /mi/sftdbaas/src/main/resources/log4j2.xml (org.apache.logging.log4j.core.LoggerContext@cf93bb) with optional ClassLoader: null
DEBUG StatusLogger Shutdown hook enabled. Registering a new one.
DEBUG StatusLogger LoggerContext[name=137e0d2, org.apache.logging.log4j.core.LoggerContext@cf93bb] started OK.


Подробнее здесь: https://stackoverflow.com/questions/784 ... ng-ignored

Вернуться в «JAVA»