Bug 3118 - ERROR No appenders could be found for category (root)
Summary: ERROR No appenders could be found for category (root)
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Log Taglib (show other bugs)
Version: unspecified
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2001-08-14 07:14 UTC by Greg Hughlett
Modified: 2005-03-20 17:06 UTC (History)
0 users

my log4j.properties file (675 bytes, text/plain)
2001-08-14 07:16 UTC, Greg Hughlett

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Hughlett 2001-08-14 07:14:15 UTC
I am not able to get the log4j.properties file properly initialized using the 
log4j example JSP pages.  I've tried it in both Tomcat (3.2) and JRun (3.1) 
with the same results.  I read the documentation and followed the suggestion of 
leaving the log4j.properties file in the WEB-INF\classes file.

Briefly here are the steps I followed to get the error:

1. unzipped the contents of "log-examples.war" into "\tomcat\webapps\log4j".
2. verified the WEB-INF\web.xml file contained the references to the log.tld.
3. verified the log4j jar files were in the WEB-INF\lib directory.
4. created a log4j webapp in Tomcat's server.xml.
5. opened url http://localhost/log4j/index.html.
6. clicked on the "test1" link and the test1.jsp displayed "Test debug; you 
should see output in the debug logs now".

I was expecting to find log messages in the Tomcat stdout file, based on the 
log4j.properties file (left it asis; no changes were made to it from the 

2001-08-14 09:28:17 - ContextManager: Adding context Ctx( /log4j )
2001-08-14 09:28:17 - ContextManager: Adding context Ctx( /servlet )
2001-08-14 09:28:17 - ContextManager: Adding context Ctx( /admin )
2001-08-14 09:28:17 - ContextManager: Adding context Ctx(  )
2001-08-14 09:28:19 - PoolTcpConnector: Starting HttpConnectionHandler on 80
2001-08-14 09:28:19 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8007
log4j:ERROR No appenders could be found for category (root).
log4j:ERROR Please initialize the log4j system properly.

2001-08-14 09:28:18 - IMPORTANT: Do not modify the generated servlets
2001-08-14 09:28:45 - JspEngine --> /test1.jsp
2001-08-14 09:28:45 - 	     ServletPath: /test1.jsp
2001-08-14 09:28:45 - 	        PathInfo: null
2001-08-14 09:28:45 - 	        RealPath: D:\tomcat\webapps\log4j\test1.jsp
2001-08-14 09:28:45 - 	      RequestURI: /log4j/test1.jsp
2001-08-14 09:28:45 - 	     QueryString: null
2001-08-14 09:28:45 - 	  Request Params: 
2001-08-14 09:28:45 - Classpath according to the Servlet Engine is: 
Comment 1 Greg Hughlett 2001-08-14 07:16:11 UTC
Created attachment 421 [details]
my log4j.properties file
Comment 2 cgu 2001-08-14 11:22:30 UTC
Wrong buglist. You probably want to try on the taglibs project.
Comment 3 Greg Hughlett 2001-08-14 13:26:42 UTC
Sorry, but according to the Taglib team this is the place to enter Taglib 
bugs...Isn't that what "Product" above means ?
Comment 4 cgu 2001-08-14 13:33:48 UTC
I am reassigning bug to the owner of Taglibs. Regards, Ceki

Comment 5 Greg Hughlett 2001-08-18 09:19:56 UTC
any idea as to when the Taglib team will be looking into my problem?
Comment 6 James Strachan 2001-08-18 12:52:32 UTC
AFAIK log4j should find the logj4.properties file in WEB-INF/classes. Maybe the 
JSP / taglib code doesn't have access to the WEB-INF/classes ClassLoader on 
Tomcat 3.2 / JRun 3.1.

I've tried this with Tomcat 4.0 beta 6 and it appears to work fine.

Maybe a workaround on Tomcat 3.2 and JRun 3.1 is to explicitly add a directory 
to your system CLASSPATH and put log4j.properties in that directory, so that 
log4j.properties can be found properly.

Or an alternative could be to write a Servlet to initialize log4j on startup.

The problem appears to be that taglib code using log4j doesn't seem to be able 
to see the log4j.properties file on the CLASSPATH - which sounds like a 
container problem.

There is nothing the taglib can do to change how log4j looks for its 
log4j.properties file, nor can it work around class loader wierdness in 
containers - so I'm afraid a work around is required to initialise log4j.

Maybe log4j could come with a standard Servlet that could be used to initialise 
log4j in circumstances such as these.