I have a simple Spring boot application that builds a jar file. I have a log4j.xml file in the src / main / resources / log4j.xml file that looks like this (main sample file from log4j docs):
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%5p [%t] (%F:%L) - %m%n"/> </layout> </appender> <appender name="R" class="org.apache.log4j.RollingFileAppender"> <param name="file" value="/tmp/logs/sample.log"/> <param name="MaxFileSize" value="100KB"/> <param name="MaxBackupIndex" value="1"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%p %t %c - %m%n"/> </layout> </appender> <root> <priority value="debug"/> <appender-ref ref="stdout"/> <appender-ref ref="R"/> </root> </log4j:configuration>
Logging only goes to the console, although (/tmp/logs/sample.log is never created), as the log4j.xml file is ignored.
The file appears in the root jar, which, I believe, is correct. What else do I need to do to get this registration configuration?
If that matters, the project uses Gradle, not Maven.
source share