i'm developing a application using spring boot version 1.3.5 (spring 4.2.6). i use log4j2 version 2.4.1 as logging system. when working on sts (spring tool suite) and executing on embeeded tomcat, the logs works fine (on console and on file) but when building a war file and deploying it on external tomcat 8 the log file is created but my logs don't appear in it.
i've looked for similar issue and tested some solutions:
but none of this solution work. the post that talks about that is: Spring-Boot Logging configuration when deployed as .war
any help or detailled answer please.
Spring Boot also supports either Log4j or Log4j 2 for logging configuration, but only if one of them is on the classpath. If you are using the starter poms for assembling dependencies that means you have to exclude Logback and then include your chosen version of Log4j instead.
Spring Boot users are only affected by this vulnerability if they have switched the default logging system to Log4J2. The log4j-to-slf4j and log4j-api jars that we include in spring-boot-starter-logging cannot be exploited on their own.
Log4j may be used as the logging framework for Apache Tomcat. This support is implemented automatically by including the log4j-api, log4j-core, and log4j-appserver jars in the boot classpath. A file named log4j2-tomcat.
If you want to configure log4j for your Spring Boot application inside Tomcat, this documentation may help you :
https://tomcat.apache.org/tomcat-8.5-doc/logging.html#Using_Log4j
Using Log4j
This section explains how to configure Tomcat to use log4j rather than
java.util.logging
for all Tomcat's internal logging.Note: The steps described in this section are needed when you want to reconfigure Tomcat to use Apache log4j for its own logging. These steps are not needed if you just want to use log4j in your own web application. — In that case, just put
log4j.jar
andlog4j.properties
intoWEB-INF/lib
andWEB-INF/classes
of your web application.The following steps describe configuring log4j to output Tomcat's internal logging.
Create a file called
log4j.properties
with the following content and save it into$CATALINA_BASE/lib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With