aspose file tools*
The moose likes Tomcat and the fly likes Logging  question : Where should I put the log4j jar file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Logging  question : Where should I put the log4j jar file?" Watch "Logging  question : Where should I put the log4j jar file?" New topic
Author

Logging question : Where should I put the log4j jar file?

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hello All,
I am trying to use log4j for the first time and have been reading all kinds of tutorials online on the subject. Unfortunately I have hit a wall and could use some help.
I have created the following log4j.properties file




I have put code into my java application to write log messages, but I don't even get to the code, I get an error on the startup of tomcat. Could this be because I do not have my log4j jar file in the correct place?
Here is the error message:

Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I put mine under myWebapp/WEB-INF/lib
I put the properties file under myWebapp/WEB-INF/classes

Works like a charm.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18880
    
    8

However you'll want to get correct data in your configuration. For example this line
log4j.appender.KimAppender=RollingFileAppender
should spell out the full class name of RollingFileAppender, which (I'm not going to look it up) is something like org.apache.something.RollingFileAppender.

The good news is that the error message
java.lang.ClassNotFoundException: RollingFileAppender
implicates that line as being wrong, so that tells us that your properties file is being found successfully.
[ September 20, 2006: Message edited by: Paul Clapham ]
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
I can't thank you enough for your responses! This was driving me crazy!

I added org.apache.log4j.RollingFileAppender where I just had RollingFileAppender and I got past that error. Now I am hitting another error but I think it is the same problem, I need to work some more on my log4j.properties file.

Thanks for helping me over that bump, will let you know if I can get past all the errors and to an actual log file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging question : Where should I put the log4j jar file?