I am trying to convert a tomcat app from log4j to log4j2. The app is still
written in Java 7 so I am using log4j2 version 2.12.1.
I am getting DEBUG information in stdout file which would indicated that the
xml file is being read. No errors are showing in the log file.
following is the log4j2.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Appenders>
<File name="File" fileName="g:\tomcat\logs\account-request.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</File>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
The classes contain:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
private static final Logger logger =
LogManager.getLogger(<className>.class);
Any ideas to why the log file is not being created
Don't think it will make a difference, but this is running under jetspeed
portal software within tomcat.
Thanks in advance.
log entries relating to Log4j
2025-01-06 12:08:38,737 localhost-startStop-5 DEBUG Apache Log4j Core 2.12.1
initializing configuration
XmlConfiguration[location=G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml]
...
2025-01-06 12:08:38,737 localhost-startStop-5 DEBUG Building
Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2025-01-06 12:08:38,753 localhost-startStop-5 DEBUG PluginManager
'TypeConverter' found 26 plugins
2025-01-06 12:08:38,769 localhost-startStop-5 DEBUG
PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n",
PatternSelector=null,
Configuration(G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml),
Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null",
noConsoleNoAnsi="null", header="null", footer="null")
2025-01-06 12:08:38,769 localhost-startStop-5 DEBUG PluginManager 'Converter'
found 44 plugins
2025-01-06 12:08:38,784 localhost-startStop-5 DEBUG Building
Plugin[name=appender,
class=org.apache.logging.log4j.core.appender.FileAppender].
2025-01-06 12:08:38,784 localhost-startStop-5 DEBUG
FileAppender$Builder(fileName="g:\tomcat\logs\account-request.log",
append="null", locking="null", advertise="null", advertiseUri="null",
createOnDemand="null", filePermissions="null", fileOwner="null",
fileGroup="null", bufferedIo="null", bufferSize="null", immediateFlush="null",
ignoreExceptions="null", PatternLayout(%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L -
%m%n), name="File",
Configuration(G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml),
Filter=null, ={})
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Starting FileManager
g:\tomcat\logs\account-request.log
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Building
Plugin[name=appenders,
class=org.apache.logging.log4j.core.config.AppendersPlugin].
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG createAppenders(={File})
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Building
Plugin[name=AppenderRef,
class=org.apache.logging.log4j.core.config.AppenderRef].
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG
createAppenderRef(ref="File", level="null", Filter=null)
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Building Plugin[name=root,
class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG
createLogger(additivity="null", level="DEBUG", includeLocation="null", ={File},
={},
Configuration(G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml),
Filter=null)
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Building
Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG createLoggers(={root})
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Configuration
XmlConfiguration[location=G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml]
initialized
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Starting configuration
XmlConfiguration[location=G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml]
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Started configuration
XmlConfiguration[location=G:\Tomcat7\temp\51-accountrequest\WEB-INF\classes\log4j2.xml]
OK.
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Shutting down
OutputStreamManager SYSTEM_OUT.false.false-1
2025-01-06 12:08:38,800 localhost-startStop-5 DEBUG Shut down
OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
2025-01-06 12:08:38,815 localhost-startStop-5 DEBUG Appender DefaultConsole-1
stopped with status true
2025-01-06 12:08:38,815 localhost-startStop-5 DEBUG Stopped
org.apache.logging.log4j.core.config.DefaultConfiguration@74b24ee OK
...
2025-01-06 12:08:38,831 localhost-startStop-5 DEBUG
LoggerContext[name=6add4d36,
org.apache.logging.log4j.core.LoggerContext@1c8ebe8f] started OK.
JetspeedContainerServlet: starting initialization of Portlet Application at:
accountrequest
JetspeedContainerServlet: initialization done for Portlet Application at:
accountrequest
Steven M Nelligan
SENIOR SOFTWARE DEVELOPER