Hello guys,

Ok, I've been using log4j for many years now, but never been lost like this: log4j gives me unwanted and wrongly formatted output.

I use log4j in all my subprojects. Each project results in a JAR file with included log4j file, so that log4j will always find a file for autoconfiguration. Usually the "master project" has a log4j on its own and that will override all the files in the jars.

This is also the situation in my current project. I have several JARs used in a WebApp running under Tomcat 4.1.12, one JAR is the ddservlet.jar. This contains a class named "DDServlet" and class named "DDConfigReader" and both classes are stuffed with log4j calls.

Look at this clipping of the logging output in the Tomcat console (log4j has logging activated also):

...
Starting Tomcat
log4j: Trying to find [log4j.xml] using StandardClassLoader
...
log4j: Trying to find [log4j.properties] using StandardClassLoader
...
log4j: Using URL [file:C:/Program Files/jakarta-tomcat-4.1.12/server/classes/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL file:C:/Program Files/jakarta-tomcat-4.1.12/server/classes/log4j.properties
log4j: Parsing for [root] with value=[INFO, Console ].
log4j: Priority token is [INFO].
log4j: Category root set to INFO
log4j: Parsing appender named "Console".
log4j: Parsing layout options for "Console".
log4j: Setting property [conversionPattern] to [%p %t %d %l - %m%n].
log4j: End of parsing for "Console".
log4j: Parsed "Console" options.
log4j: Parsing for [nl.knowledgeplaza.dd.ddservlet.DDServlet] with value=[DEBUG].
log4j: Priority token is [DEBUG].
log4j: Category nl.knowledgeplaza.dd.ddservlet.DDServlet set to DEBUG
log4j: Handling log4j.additivity.nl.knowledgeplaza.dd.ddservlet.DDServlet=[null]
log4j: Finished configuring.
...



What you see is that it uses the one configuration file, ignoring all the ones in the JARs:
- base priority is INFO
- one output stream "Console"
- DDServlet is specifically set to DEBUG
All perfect and matches with the configuration file:


log4j.rootCategory=INFO, Console

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%p %t %d %l - %m%n

log4j.category.nl.knowledgeplaza.dd.ddservlet.DDServlet=DEBUG


Now the catch, this is the actual output:


...
INFO main 2003-10-14 14:25:42,694 org.apache.commons.modeler.Registry.loadRegistry(Registry.java:264) - Loading registry information
...
Initializing Coyote HTTP/1.1 on port 8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.12


INFO main 2003-10-14 14:26:01,311 org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:166) - Starting Coyote HTTP/1.1 on port 8080
...
Thread-6 2003-10-14 14:26:05,016 nl.knowledgeplaza.dd.support.DDConfigReader.getValue(DDConfigReader.java:57) - cache [EMAIL PROTECTED]:/Documents and Settings/toeu/My Documents/knowledgeplaza/dd2.1.2d/etc/pdp.xml


Thread-6 2003-10-14 14:26:05,036 nl.knowledgeplaza.dd.support.DDConfigReader.getValue(DDConfigReader.java:73) - reading from file C:/Documents and Settings/toeu/My Documents/knowledgeplaza/dd2.1.2d/etc/pdp.xml
...



First block shows a correct INFO log4j output line, 2nd block also, and then out of the blue log4j switches to another layout (losing the priority), and log4j is outputting lines it should not! I checked the lines in the source and these are DEBUG lines.


I did not mix up declarations or anything:

public class DDServlet extends HttpServlet
{
...
static org.apache.log4j.Category cLog4J = org.apache.log4j.Category.getInstance(DDServlet.class.getName());




public class DDConfigReader
{
...
static org.apache.log4j.Category cLog4J = org.apache.log4j.Category.getInstance(DDConfigReader.class.getName());



Where in the hell does log4j get the idea of outputting these lines??? And incorrectly formatted also. It would suggest log4j took another configuration file, but that is not shown in the output.



Out of sheer desparation I changed the configuration in the JAR file, but that makes no difference. Adding the priority does not change the output. Typical is the fact that org.apache.common, etc classes are logged correctly, but as soon as it is logging my classes, it changes.


I'm using log4j 1.2.8.

X-|

Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to