This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Redirecting messages to a file ... append Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Redirecting messages to a file ... append" Watch "Redirecting messages to a file ... append" New topic

Redirecting messages to a file ... append

Tokunbo Oke
Ranch Hand

Joined: Sep 09, 2003
Posts: 57
Please tell me how to configure Tomcat/Struts so that
error messages are sent to a file, not the console?

I am using tomcat-5.0.27

I am using simpleLog for logging error messages. This is working fine.

The output of the code below goes to Eclipse console.
What I want is for the output to go into a file.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class CargoExceptionHandler extends
ExceptionHandler {
public ActionForward execute( Exception ex,
ActionMapping mapping,
ActionForm form,
) throws ServletException{

Log log =

//Which Logger is being Used?

System.out.println("The Log being used >>>
" + log);

//Create a dummy exception to depict
exception logging

Exception e = new Exception("A DUMMY

//Log TRACE if enabled

if (log.isTraceEnabled()) {

log.trace("TRACE TEST");

log.trace("TRACE TEST", e);


//Log DEBUG if enabled

if (log.isDebugEnabled()) {

log.debug("DEBUG TEST");

log.debug("DEBUG TEST", e);


//Log INFO if enabled

if (log.isInfoEnabled()) {"INFO TEST");"INFO TEST", e);


//Log WARN if enabled

if (log.isWarnEnabled()) {

log.warn("WARN TEST");

log.warn("WARN TEST", e);


//Log ERROR if enabled

if (log.isErrorEnabled()) {

log.error("ERROR TEST");

log.error("ERROR TEST", e);


//Log FATAL if enabled

if (log.isFatalEnabled()) {

log.fatal("FATAL TEST");

log.fatal("FATAL TEST", e);



Thank you.
I agree. Here's the link:
subject: Redirecting messages to a file ... append
Similar Threads
Help log4j SysLogAppender
using and configuring log4j in my application or log4j.xml
log4j:WARN No appenders could be found for logger (LogClass)
Help log4j SysLogAppender