Link to home
Start Free TrialLog in
Avatar of vassim1977
vassim1977

asked on

Configuring Tomcat 5.5 to redirect stdout and stderr to the web application’s log file

What are the steps in configuring Tomcat 5.5 to redirect stdout and stderr to the web application’s log file?  Please provide detailed steps and a working configuration
Avatar of ozlevanon
ozlevanon

This is not a specific solution for Tomcat, but you can redirect the stdout and stderr in Java using System.setOut and System.setErr (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#setOut(java.io.PrintStream))

If you create a PrintStream implementation which redirects output to your application log, and use it in setOut and setErr it will take away the messages from catalina.out and print them to your log.

Of course, if you want, you can always print the to both by having your implementation print the data both to your application log and to the original System.out and System.err
The cleaner way would be to use log4j or any logger api and use those API's in your application for logging.
This way you can clearly separate out the tomcat logging and the application logging.
ASKER CERTIFIED SOLUTION
Avatar of Venabili
Venabili
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial