> Whilst developing servlets my development
> team often put System.err.println() statements in the servlet code.
> Unfortunately, these error strings always get printed to main apache
> error log and not the virtual host or servlet zone's error log. Has anyone
> encountered this problem before and found a solution to isolate the errorlog output.
have them use
log("error string);
or
getServletContext.log(e, "an error ");
or
use the following and write the error stack trace back to the browser or to the log.
/* PrintStackTraceAsString from com.oreilly.servletServletUtils from
Java Servlet Programming, by Jason Hunter and William Crawford, O'Reilly, 1998
*/
public String getStackTraceAsString(Exception e){
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(bytes, true);
e.printStackTrace(writer);
return bytes.toString();
}brettATknightsofthenetDOTcom |