Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Log4j only reads log4j.properties in $CATALINA_HOME/lib

 
Ranch Hand
Posts: 163
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic