• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where's printstackTrace() output ?

 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be simpler to use the ServletContext log( msg, throwable ) method.

Bill
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic