You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by nj...@ghx.com on 2002/07/12 22:46:06 UTC

Problem initializing Log4j during Tomcat startup

I'm trying to get log4j initialized properly when starting up Tomcat, but I
get the following error in my console:

log4j:WARN No appenders could be found for logger
(org.apache.commons.digester.Digester).
log4j:WARN Please initialize the log4j system properly.
Starting service Tomcat-Standalone
Apache Tomcat/4.1

I've placed the log4j.properties file in my WEB-INF/classes directory as the
short manual suggests.  The manual indicates that Log4j will automatically
find the properties file and initialze itself if it located here.  Here is
my log4j.properties:

log4j.rootLogger=DEBUG, A1

log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=example.log

log4j.appender.A1.MaxFileSize=100KB
log4j.appender.A1.MaxBackupIndex=1

log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%p %t %c - %m%n

As you can see I want to write debug messages to example.log.  Interestingly
enough when I start Tomcat it DOES create an example.log file (in
C:\jakarta-tomcat-4.0\bin), but none of my messages get output to it when I
try running my application.  So it tells me that it at least finds my
log4j.properties file and creates an example.log file but other problems
seem to exist.  If there was no problem initializing I wouldn't get that
error in the console, correct?  Does my log4j.properties look correct?

I do set my log4j-1.2.5.jar in my classpath in the setclasspath.bat.  I'm
running a JSP that calls a class file that makes a call to Logger.  Here are
the relevant lines of code I'm using in my class file to call log4j:

import org.apache.log4j.Logger;
<snip>
static Logger logger = Logger.getLogger(MyClass.class);
<snip>
logger.debug("GOT HERE!");

The class compiles/executes fine, but my log message never seems to write
anything to example.log.  I'm assuming this is because it is still having
problems initializing during start up.  I've searched the net and archives
to help me resolve this, but to no avail.

I'm running Win2k with Tomcat 4.1 and log4j-1.2.5.

Thanks very much to any one willing to help me with this.
Nathan


RE: Problem initializing Log4j during Tomcat startup

Posted by Roland Berger <be...@bluewin.ch>.
I had the same problem with my web app. I use struts which itself is using
the commons package.

I initialized log4J as a separate servlet like Ceki has written in his short
manual http://jakarta.apache.org/log4j/docs/manual.html section
Initialization servlet. After doing this log4J could ininitialize without an
error message.
But if you only use the root category/looger you will then also receive the
log statments from the commons package.

I didn't have the time to dig deep enough to find the root problem.

To all Container developer. It would be cool to configure log4J not only per
web application put also for a set of jar's in a web app.

Regards
Roland

-----Original Message-----
From: njantz@ghx.com [mailto:njantz@ghx.com]
Sent: Freitag, 12. Juli 2002 22:46
To: log4j-user@jakarta.apache.org
Subject: Problem initializing Log4j during Tomcat startup



I'm trying to get log4j initialized properly when starting up Tomcat, but I
get the following error in my console:

log4j:WARN No appenders could be found for logger
(org.apache.commons.digester.Digester).
log4j:WARN Please initialize the log4j system properly.
Starting service Tomcat-Standalone
Apache Tomcat/4.1

I've placed the log4j.properties file in my WEB-INF/classes directory as the
short manual suggests.  The manual indicates that Log4j will automatically
find the properties file and initialze itself if it located here.  Here is
my log4j.properties:

log4j.rootLogger=DEBUG, A1

log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=example.log

log4j.appender.A1.MaxFileSize=100KB
log4j.appender.A1.MaxBackupIndex=1

log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%p %t %c - %m%n

As you can see I want to write debug messages to example.log.  Interestingly
enough when I start Tomcat it DOES create an example.log file (in
C:\jakarta-tomcat-4.0\bin), but none of my messages get output to it when I
try running my application.  So it tells me that it at least finds my
log4j.properties file and creates an example.log file but other problems
seem to exist.  If there was no problem initializing I wouldn't get that
error in the console, correct?  Does my log4j.properties look correct?

I do set my log4j-1.2.5.jar in my classpath in the setclasspath.bat.  I'm
running a JSP that calls a class file that makes a call to Logger.  Here are
the relevant lines of code I'm using in my class file to call log4j:

import org.apache.log4j.Logger;
<snip>
static Logger logger = Logger.getLogger(MyClass.class);
<snip>
logger.debug("GOT HERE!");

The class compiles/executes fine, but my log message never seems to write
anything to example.log.  I'm assuming this is because it is still having
problems initializing during start up.  I've searched the net and archives
to help me resolve this, but to no avail.

I'm running Win2k with Tomcat 4.1 and log4j-1.2.5.

Thanks very much to any one willing to help me with this.
Nathan



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>