cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong log4j.xml used

Julien_Eluard
Confirmed Champ
Confirmed Champ

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).

1 ACCEPTED ANSWER

Julien_Carsique
Elite Collaborator
Elite Collaborator

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.

View answer in original post

8 REPLIES 8

Florent_Guillau
World-Class Innovator
World-Class Innovator

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

Julien_Eluard
Confirmed Champ
Confirmed Champ

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

Julien_Carsique
Elite Collaborator
Elite Collaborator

The nuxeo-launcher's log4j is used and must not be removed.

Julien_Eluard
Confirmed Champ
Confirmed Champ

Yes not sure why I get a different ClassLoader.

Julien_Carsique
Elite Collaborator
Elite Collaborator

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.

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

Most people don't need to change Launcher logging and there are [debug options ('-d' and '-dc')][1] 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')...

Makes sense! '-d' definitively does the trick.