• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Redirecting messages to a file ... append

Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()) {

log.info("INFO TEST");

log.info("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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic