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

Reply via email to