Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
2.17.1
-
None
-
Windows 10
Amazon Linux
Description
I am attempting to use the log4j bridge with log4j2, and cannot use system properties to set a location for my log files.
Reported here: stackoverflow
My log4j.xml file:
log4j-dev.xml
...
<appender name="DAILY" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${catalina.base}/logs/etl.log"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="GATEWAY: %p %d [%t] %c{1}.%M(%L) | %m%n"/>
</layout>
</appender>
...
The setenv.bat entry where I define which log4j.xml to use:
-Dlog4j2.debug=true -Dlog4j.configuration=log4j-dev.xml
The properties shown in the tomcat log illustrating that the system property in question is being supplied to the log4j1 bridge
...
Command line argument: -Dlog4j2.debug=true
Command line argument: -Dlog4j.logDir=C:\dev\apache-tomcat-8.5.50\logs
Command line argument: -Dlog4j.configuration=log4j-dev.xml
Command line argument: -Dcatalina.base=C:\dev\apache-tomcat-8.5.50
Command line argument: -Dcatalina.home=C:\dev\apache-tomcat-8.5.50
Command line argument: -Djava.io.tmpdir=C:\dev\apache-tomcat-8.5.50\temp
...
And the part of the log that shows where the log file is successfully created and what path it is using:
...
DEBUG StatusLogger Class name: [org.apache.log4j.RollingFileAppender]
DEBUG StatusLogger Parsing layout of class: "org.apache.log4j.PatternLayout"
DEBUG StatusLogger PluginManager 'Converter' found 47 plugins
TRACE StatusLogger New file '${catalina.base}/etl.log' created = true
DEBUG StatusLogger Returning file creation time for C:\dev\apache-tomcat-8.5.50\bin\${catalina.base}\etl.log
DEBUG StatusLogger Starting RollingFileManager ${catalina.base}/etl.log
...
The log file is being created in a folder named "${catalina.base}", in whatever directory I'm in when I start tomcat. The issue is similar to this Jira issue, LOG4J2-2951, and that issue was just resolved in early December.
Attachments
Issue Links
- links to