Closed
Description
The logging of the PID with Log4j2 is behaving rather strangely. For the first few log lines its ????
, it then changes to the process's actual PID, before changing back to ????
:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
2017-04-07 14:37:36.443 INFO ???? --- [ main] s.a.l.SampleActuatorLog4J2Application : Starting SampleActuatorLog4J2Application on aw-rmbp.home with PID 56404 (/Users/awilkinson/dev/spring/spring-boot/master/spring-boot-samples/spring-boot-sample-actuator-log4j2/target/classes started by awilkinson in /Users/awilkinson/dev/spring/spring-boot/master/spring-boot-samples/spring-boot-sample-actuator-log4j2)
2017-04-07 14:37:36.450 INFO ???? --- [ main] s.a.l.SampleActuatorLog4J2Application : No active profile set, falling back to default profiles: default
2017-04-07 14:37:36.505 INFO ???? --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7776ab: startup date [Fri Apr 07 14:37:36 BST 2017]; root of context hierarchy
2017-04-07 14:37:37.815 INFO ???? --- [ main] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2017-04-07 14:37:37.838 INFO 56404 --- [ main] o.a.c.c.StandardService : Starting service Tomcat
2017-04-07 14:37:37.839 INFO 56404 --- [ main] o.a.c.c.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.13
2017-04-07 14:37:37.924 INFO 56404 --- [ost-startStop-1] o.a.c.c.C.[.[.[/] : Initializing Spring embedded WebApplicationContext
2017-04-07 14:37:37.925 INFO ???? --- [ost-startStop-1] o.s.w.c.ContextLoader : Root WebApplicationContext: initialization completed in 1425 ms
2017-04-07 14:37:38.155 INFO ???? --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2017-04-07 14:37:38.155 INFO ???? --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-04-07 14:37:38.155 INFO ???? --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
The pid is made available to Log4j2 as a system property and the system property is resolved during initialisation. If that initialisation is now happening earlier than before, it would explain why we see ????
. Interestingly, the three lines where the PID is correct are from Tomcat. It uses JUL so it's taking a different route into Log4j2 than the other logging which is all from Spring Boot or Spring Framework.
Two related changes have been made recently that might have triggered this:
- Upgrading to Log4j 2.8 (from 2.7)
- The introduction of Spring Framework's own Commons Logging adapter which delegates to Log4j2 when it's on the classpath
Metadata
Metadata
Assignees
Labels
No labels