Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat logging

 
Padmanathan vswamy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Padmanathan AV", please check your private messages for an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Explore the use of Log4J rather than System.out.
 
Padmanathan vswamy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Padmanathan AV", please check your private messages for an important administrative matter. Again.
 
Padmanathan vswamy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Updated display name..
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic