Howdy, >I am running Tomcat 4.1.24 on Windows NT 4.0. When I get a runtime error >in my servlet, I'm getting stack traces on the console instead of in the >log. Is there a way to force all output to the log. I have a log >specified that it writes to while the container loads, but for some reason, >runtime errors. Should I be doing something other than >"exception.printStackTrace();". If I could get a copy of the stack trace, >I could use getServletContext().log().
Several options: -Add swallowOutput="true" to your context definition, and the console output will be redirected to your servlet context log, as if you had used ServletContext#log(...). - Use a StringWriter to get the stack trace, e.g. for Exception e, StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); pw.flush(); getServletContext().log(sw.toString()); - Use a logging system like log4j and just do try { ... } catch(Exception e) { LOGGER.error("Messed up: ", e); } Yoav Shapira 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]