IDependOn-Set: 1
IDependOn-Set: 284
IDependOn-Set: 288
IDependOn-Set: 289
IDependOn-Set: trash
LastModifiedSecs: 935437487
Parent: trash
SequenceNumber: 3
Title: Logging Servlet Output
Part: 0
Author-Set: brett@knightsofthenet.com
LastModifiedSecs: 935339776
Type: monospaced
Lines: 26
> 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();
        }
EndPart: 0
