Hello all,

I start using Log4j2 2.5 with an Apache Tomcat container. The integration works 
so fare, but I have identified some issues with the exposed Jconsole Mbean.

1.       The loggers run into a NullPointer if someone use an incorrect logger 
name. After this nullpointer, the Mbean display "Unavailable" for this logger, 
so the whole config file must be reloaded. Here the log output of my local 
testing. I would expect that the logger do not except the incorrect value and 
internally remain with the previous value (maybe throw a 
IllegalArgumentException to give a feedback to the user).

validating [row=4, column=1]: Level=asdfasdf

setAttribute(Level=asdfasdf)

java.lang.NullPointerException

               at 
org.apache.logging.log4j.core.config.LoggerConfig.getLevel(LoggerConfig.java:261)

               at 
org.apache.logging.log4j.core.Logger$PrivateConfig.<init>(Logger.java:312)

               at 
org.apache.logging.log4j.core.Logger.updateConfiguration(Logger.java:293)

               at 
org.apache.logging.log4j.core.LoggerContext.updateLoggers(LoggerContext.java:595)

               at 
org.apache.logging.log4j.core.LoggerContext.updateLoggers(LoggerContext.java:585)

               at 
org.apache.logging.log4j.core.jmx.LoggerConfigAdmin.setLevel(LoggerConfigAdmin.java:82)

2.       The ConfigLocationUri is also editable in the Mbean, but the behavior 
is a bit strange. If I type in the correct location e.g. "file:/opt/tomcat 
/apache-tomcat/conf/log4j2.xml" it correctly load the file once. But afterwards 
the "ConfigLocationUri" has automatically changed to 
"file:/opt/tomcat/apache-tomcat/bin/file:/opt/tomcat/apache-tomcat/conf/log4j2.xml"
 which is no longer a valid path. So it seems to log4j prefixes 
"file:/opt/tomcat/apache-tomcat/bin/" (this folder is the root folder where 
tomcat was started from) to my input.

3.       The JMX ConfigLocationUri seems to partially struggle with 
"classpath:" Uris that point to the classpath of one of the webapps (I use 
log4j-web.jar in the webapp). I saw that the LoggerContextAdmin internally use 
"new URL(configLocation);" to load the file. Is it may be necessary to first 
identify the correct Classloader?



Any feedback on my reported issues are welcome.

Kind regards,
Thomas


InterComponentWare AG:
Vorstand: Peter Kirschbauer (Vors.), Matthias Gl?ck
Aufsichtsratsvors.: Prof. Dr. Christof Hettich
Unternehmenssitz: 69190 Walldorf, Altrottstra?e 31
AG Mannheim HRB 351761 / USt.-IdNr.: DE 198388516

Reply via email to