File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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: 2591

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
Sonny Gill LinkedIn
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2591

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
Don't get me started about those stupid light bulbs.
subject: Logs not getting created
It's not a secret anymore!