Wrong log4j.xml used

It appears log4j loads the log4j.xml embedded in nuxeo-launcher.jar as opposed to the one in lib/. Is this the intended behavior? It makes lib/log4j.xml essentially useless. A workaround is to use -Dlog4j.configuration to directly reference lib/log4j.xml.

You can easily check this by adding -Dlog4j.debug as property to the launching JVM (in nuxeoctl).

(this is with latest published 5.7-SNAPSHOT).

0 votes

1 answers

2751 views

ANSWER

It works for me, using a snapshot from Friday I get:

log4j: Trying to find [log4j.xml] using context classloader org.apache.catalina.loader.StandardClassLoader@1976bf9e.
log4j: Using URL [file:/opt/nuxeo/lib/log4j.xml] for automatic log4j configuration.
03/25/2013

Weird. I'm using the nuxeo-cap.zip distribution here. Then I launch nuxeo with either nuxeoctl console or nuxeoctl start. I get:

>Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@efae3b.

>Using URL [jar:file:/var/lib/openshift/…/app-root/runtime/repo/bin/nuxeo-cap-5.7-I20130322_1136-tomcat/tmp/nuxeo-launcher-22340.jar!/log4j.xml] for automatic log4j configuration.

What's strange is that log4j tries to load the conf using a different ClassLoader than in your case..

Is the log4j.xml file from nuxeo-launcher.jar used in some way? I could remove it if not.

03/25/2013

The nuxeo-launcher's log4j is used and must not be removed.
The workaround with log4j.configuration is valid. However, I'd like to understand why you don't have the same classloader in your case (the org.apache.catalina.loader.StandardClassLoader will preferably load the lib/log4j.xml one).
03/25/2013

Yes not sure why I get a different ClassLoader.

I can reproduce exact same behavior on an OpenShift node and my local MacOSX env using 5.7-SNAPSHOT and latest 5.6 (HF13).

Do you have any idea how I could debug that?

03/25/2013



Hello,

Are you sure you have an issue?
Instead of editing nuxeoctl, please add the following to nuxeo.conf: JAVA_OPTS=$JAVA_OPTS -Dlog4j.debug. Then run ./bin/nuxeoctl console in order to see the server's Log4J initialization.

I activated log4j.debug on the Launcher (in nuxeoctl script) and on Nuxeo (in nuxeo.conf):

log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@24ee5d13.
log4j: Using URL [jar:file:/home/julien/.../nuxeo-cap-5.7-SNAPSHOT-tomcat/tmp/nuxeo-launcher-22833.jar!/log4j.xml] for automatic log4j configuration.
Detected Tomcat server.
(...)
Configuration files generated.
log4j: Trying to find [log4j.xml] using context classloader org.apache.catalina.loader.StandardClassLoader@79e4620e
log4j: Using URL [file:/home/julien/.../nuxeo-cap-5.7-SNAPSHOT-tomcat/lib/log4j.xml] for automatic log4j configuration.

It uses the right log4j configuration for each.

1 votes



You are right I didn't realize there were 2 JVM involved here.

As the issue I was trying to troubleshoot happens during the launching process modifying lib/log4j.xml was ineffective (as as expected the one bundled in nuxeo-launcher.jar is picked up).

May I ask why you chose this option? Seems like it could be valuable to change logging configuration for the launching JVM too.

03/25/2013

Most people don't need to change Launcher logging and there are debug options ('-d' and '-dc') which allow to debug the Launcher without having to edit the log4j configuration. Also, I planned to allow dynamic log4j customization from an embedded Nuxeo Shell ('nuxeoctl shell')…

Finally, if you need more customization, you can still use the -Dlog4j.configuration parameter or directly edit nuxeo-launcher.jar.

03/26/2013

Makes sense! '-d' definitively does the trick.
03/26/2013