GeeCON Prague 2014*
The moose likes Tomcat and the fly likes Tomcat logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat logging" Watch "Tomcat logging" New topic
Author

Tomcat logging

Padmanathan vswamy
Greenhorn

Joined: May 04, 2009
Posts: 3
I am using tomcat5.5 in my machine. By default system.out.println(...) is being logged in file located at ${catalina.base}/logs which is located in c drive. I dont have write access for c: drive so I am not able to delete the existing log files. So I want to write the sysout and syserr log in d:/logs folder. How to configure it?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

"Padmanathan AV", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

Explore the use of Log4J rather than System.out.
Padmanathan vswamy
Greenhorn

Joined: May 04, 2009
Posts: 3
We started to use log4j ... but there are lot of sysout in the existing application. So I want those sysout and syserr log in d:/logs folder instead of the tomcat_home/logs...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

"Padmanathan AV", please check your private messages for an important administrative matter. Again.
Padmanathan vswamy
Greenhorn

Joined: May 04, 2009
Posts: 3
Updated display name..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

Padmanathan vswamy wrote:Updated display name..


Thank you.

I'm afraid that there's no way to reroute the System.out and System.err calls. Which is one of the biggest reasons not to use them in the first place. Except in the case of stand-alone Unix-style non-GUI applications, the System io services are something that is best kept as a last resort. You can never be totally sure where or even if the output to System.out and System.err will be displayed.

The easiest thing to to is take your favorite editor and do a global search/replace

From System.out.println To log.info

From System.err.println To log.severe

You may also need to convert printStackTrace calls. If you use the Java built-in logger, that would mean converting

ex.printStackTrace();

to

log.log(Level.SEVERE, "Exception", ex);

Which CAN be done with a text search/replace, but it's trickier. Fortunately, there's probably not as many of them as there are println's.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: Tomcat logging