I have a log4j2 configuration file for a web app running on Tomcat 8 that looks like this
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30" status="trace" strict="true">
<Properties>
<Property name="logdir">/path/to/log/dir</Property>
<Property name="filename">somelogfile.log</Property>
</Properties>
<Loggers>
<Logger name="some.package.name" level="debug" additivity="false">
<AppenderRef ref="RollingFile"/>
</Logger>
</Loggers>
<Appenders>
<RollingFile name="RollingFile" fileName="${logdir}/${filename}" filePattern="${logdir}/${filename}.%d{yyyyMMdd}.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="6" modulate="true"/>
</Policies>
</RollingFile>
</Appenders>
</Configuration>
I see that my web app writes to the log file, but the %t pattern I have for thread name doesn't seem to resolve, so I get log statements like this
2017-06-10 20:34:51,696 DEBUG s.p.n.SomeServlet [%t] some log message
Notice I get %t instead of the thread name
So to troubleshoot this I started Tomcat using the option
-Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE
and I see the following messages print in catalina.out when the webapp is deploying and log4j2 is initializing.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern
2017-06-10 19:51:14,277 localhost-startStop-1 DEBUG PluginManager 'Converter' found 41 plugins
2017-06-10 19:51:14,609 localhost-startStop-1 ERROR Unrecognized format specifier [t]
2017-06-10 19:51:14,614 localhost-startStop-1 ERROR Unrecognized conversion specifier [t] starting at position 6 in conversion pattern.
my web app has the following jar files among others
WEB-INF/lib/log4j-api-2.8.2.jar
WEB-INF/lib/log4j-core-2.8.2.jar
WEB-INF/lib/log4j-web-2.8.2.jar
Not sure what is causing %t to print instead of the actual thread name.
.
2017-06-12 16:22:29,050 INFO s.p.name [main] some log message
. – Itinerate