This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Logs not getting created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Logs not getting created" Watch "Logs not getting created" New topic

Logs not getting created

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

This must be easy, and I am sure I have done itbefore, but can't find thsi now.

I am working on few classes that would be used by servlets, these classes use logging feature. I am using -

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Whe I test them as standalone classes, the logs show up on the console, but while running through the servlets, these logs are not getting saved under "tomcat/logs" directory. Where & how can I specify that the logs should go under "logs"???

- Manish
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211


Commons Logging is just a think wrapper around the underlying logging API, usually it is LOG4J or in case of Java 1.4, the java.util.logging package, so that is where you have to configure your logging.

You may need to look up how to do it for your setup, but by default the loggers are only assigned a Console handler, you have to add a File handler that will write to the location you want.

If you are using standard Java logging, this may help -


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

I am using log4j I beliveve. can you pint out how can I do this?
All the system.out.println are getting written to the log file correcly. Only my log.error() are not getting written I wonder why???

- Manish
I agree. Here's the link:
subject: Logs not getting created
Similar Threads
servlet/jsp not running in tomcat
Problem with accessing servlet from browser
saving my servlets and html files?
Configuring packages and class paths
classes other than sevlets that are not jar-ed