You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jim Moore <ji...@veritas.com> on 2001/01/30 17:30:09 UTC

Capturing System.err

How are people capturing things being sent to System.err?  Prior to using
log4j the solution was simple: I was logging out to a file and did a
System.setErr(...) to a FileWriter to the file.

Unfortunately, that doesn't work with log4j and it's a real problem.  I've
created a ThreadGroup that my app runs in to capture exceptions that way,
but there are other places -- like java.awt.EventDispatchQueue -- that
bypass that mechanism.  (There's a hack [Sun's word] to capture exceptions
in EventDispatchQueue, but that's only with JDK 1.2 and above.)  There's
other places as well that like to simply spit out to System.err.  If I've
got an SMTPAppender sending me messages, for example, it could easily be
vitally important to debugging the problem to know that EventDispatchQueue
had hit an OutOfMemoryException which is what generated the error that sent
the email.

Ideas?

-Jim Moore