aspose file tools*
The moose likes Servlets and the fly likes Where's printstackTrace() output ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Where Watch "Where New topic
Author

Where's printstackTrace() output ?

Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
When my Model catches an exception then re-throws it to the Controller which calls printStackTrace() , the Apache-Tomcat logs do not record where the Model had the problem . Can AT be configured to write printStackTrace() to the logs?
I know that I can put printStackTrace (PrintStream) into a String and log() that String (the String has all that I require) , but do I need to do this ?
Thank you.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
It might be simpler to use the ServletContext log( msg, throwable ) method.

Bill
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Apache Tomcat typically writes anything from STDOUT to logs/catalina.out .

My personal preference for logging is Apache log4j - http://logging.apache.org/log4j/ . Logging is all controlled by a properties file, allowing you to easily change logging levels and appenders (log files) without touching your java code. Each logging method can take a message and/or an optional Exception, which will give you similar output to calling Exception.printStackTrace().


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Peter : I think Log4J is really for continuous monitoring and logging of events.
Bill's solution gives the same results and is simpler than the one I mentioned.
Thank you both.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where's printstackTrace() output ?