Thanks! This is a huge help! ----- Original Message ----- From: "Shapira, Yoav" <[EMAIL PROTECTED]> To: "Log4J Users List" <[EMAIL PROTECTED]> Sent: Wednesday, September 15, 2004 9:56 AM Subject: RE: logging a stack trace
Hi, Logger.error("Exception: ", e); Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Jeff Drew [mailto:[EMAIL PROTECTED] >Sent: Wednesday, September 15, 2004 9:57 AM >To: Log4J Users List >Subject: logging a stack trace > >How do I write a stack trace to a log? >I found some references in the mail archives, but couldn't find a solution. >I couldn't find it in Ceki's book. Here's a simple example of my goal. >Thanks! > >public class LogStackTrace { > static Logger logger = Logger.getLogger("LogStackTrace"); > > public static void main(String[] args) { > BasicConfigurator.configure(); > > try { > throw new NullPointerException(); > } catch (Exception e) { > e.printStackTrace(); // *** how do I output this to log4j? *** > logger.error(e.getStackTrace()); // just writes the object id > } > } >} >Jeffrey Drew >President and Founder >Trading Metrics, Inc. >917-453-0302 This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]