Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4j only reads log4j.properties in $CATALINA_HOME/lib

 
Bill Clar
Ranch Hand
Posts: 163
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I've hit a snag in my efforts to migrate from Tomcat 5.5.4 to Tomcat 6.0.18. My goal is to have a catalina.out log for stderr, and a webapps.log for my application. Upon startup of Tomcat 6.0.18, only the catalina.out log exists and it contains all output from the webapp.

In Tomcat 5.5.4, log4j, version 1.2.9, looks for log4j.properties in my WEB-INF/classes directory without a problem.

In Tomcat 6.0.18, it appears that log4j, version 1.2.15, is looking
for the log4j.properties file in the $CATALINA_HOME/lib folder only.

I've researched this problem on Tomcat's bug database and found a bug with the same problem. However, the two solutions provided, while helpful, don't give a complete answer.

"You should customize the classloader hierarchy to fit your needs, then."
"Take a look at TOMCAT_HOME/conf/catalina.properties."

Both of these answers lead me to the catalina.properties file and it's classloading capabilities. This is where I'm stuck. I'm unable to find sufficient documentation on catalina.properties.

If anyone could point me in the right direction, I'd greatly appreciate it.

Bill Clar

System: Fedora, Release 9 (Sulphur)
Kernel Linux 2.6.27.5-37.fc9.i686
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Tomcat 6 and log4j, with the log4j.properties file in my WEB-INF/classes directory without a problem.
As I understand it, log4j looks on the classpath for the log file; and, clearly, the classes directory is part of the generated classpath used by webapps in Tomcat.

Are you sure there isn't some other problem?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still using Tomcat 5, but may be switching to Tomcat 6 in the near future.

I currently put the log4j.properties file in $CATALINA_HOME/common/classes so that my properties will be picked up by all web apps and Tomcat itself.

Ben, what's the equivalent location in Tomcat 6?
 
Bill Clar
Ranch Hand
Posts: 163
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
I'm using Tomcat 6 and log4j, with the log4j.properties file in my WEB-INF/classes directory without a problem.
As I understand it, log4j looks on the classpath for the log file; and, clearly, the classes directory is part of the generated classpath used by webapps in Tomcat.

Are you sure there isn't some other problem?


It could be another problem, as I'm slowly coming up to speed on Tomcat 6. What I'll do is turn on the debugging and verify that the log file is in the classpath.

Thanks for the help!

Bill Clar
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
I'm still using Tomcat 5, but may be switching to Tomcat 6 in the near future.

I currently put the log4j.properties file in $CATALINA_HOME/common/classes so that my properties will be picked up by all web apps and Tomcat itself.

Ben, what's the equivalent location in Tomcat 6?


tomcat/common/lib|classes and tomcat/shared/lib|classes have been merged to tomcat/lib and tomcat/classes.

I've only ever used log4j within my own webapps so I'm not sure if anything has changed regarding logging at a global level.
 
Bill Clar
Ranch Hand
Posts: 163
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used option -Dlog4j.debug for some help and it turns out my webapp/WEB-INF/classes/log4j.properties file isn't being loaded. Only the $CATALINA_HOME/lib/log4j.properties is loading. I turned on the DEBUG level of the rootLogger and verified that the webapp/WEB-INF/classes is in the classpath.

I'm quickly running out of time and options. I don't have time to acquire and learn a new application server, like Glassfish, but I may be forced to.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic