The moose likes Tomcat and the fly likes One Log File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "One Log File" Watch "One Log File" New topic

One Log File

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I am trying to figure out how to get all of my logging to use one log file. Currently when I start tomcat as a service it writes to stderr.log, stdout.log as well as a log file I have configured using Log4j. I would like all logs including startup/shutdown logs that are currently going to stdout.log/stderr.log to go to the file I write to using Log4j.

If I start tomcat using catalina.bat it doesn't do this (bc it writes to the console window) but I would like to send all those startup/shutdown messages to the log that Log4j uses if I start tomcat as a service.

Any help would be appreciated.
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
After toying with this for a while...I can't seem to find a clean solution. It looks like these are the only choices I'm left with.

1) Configure a <Logger> element for the Context that catches any logging not sent to the Log4j log file. This means I would have a stdout.log, stderr.log, log from the <Logger> element, and a log for Log4j. That's a lot of log files...

2) Not configure a <Logger> element for the Context. This means any logging not sent to the Log4j file will go to either stdout.log or stderr.log. Those files could get big and aren't rotated like my Log4j file. Not exactlly ideal either.

3) Don't install Tomcat through the .exe file. Unpackage it, set the environment variables, and set it up as a serivce through a script such as the one mentioned at link setting the same file that Log4j uses for the -out and -err parameters. This means that all logging (startup/shutdown) will go to this one log file. But it also means messing with the install (deviating from the .exe) which scares me a little.

Unless someone has a better idea...I guess it's one of the three above.

I agree. Here's the link:
subject: One Log File
It's not a secret anymore!