DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31056>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31056

(PATCH) Console appender doesn't notice changes to System.out/System.err

           Summary: (PATCH) Console appender doesn't notice changes to
                    System.out/System.err
           Product: Log4j
           Version: 1.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Appender
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The ConsoleAppender can be configured to log messages to Standard Out or
Standard Error.

Both of these streams may be redirected using System.setErr and System.setOut.

In the current implementation, a Console appender stores a reference to it's
destination stream when it is initially configured and will continue to use that
reference unless it is reconfigured. As a result, a ConsoleAppender will
continue to log to the old stdout/stderr destination even after the system
stream has been redirected.

Since log4j may be automatically configured very early in the application
lifecycle (in the case of my project, due to a call to Logger.getLogger in a
static member initialization), it can be difficult or impossible to be sure that
any necessary redirection takes place before log4j initialization.

My patch proposes a solution to this problem. The modified ConsoleAppender
overrides the AppenderSkeleton.append( LoggingEvent ) method to verify that the
system's stream has not changed since it was last configured. If it has changed,
the ConsoleAppender updates itself to use the new reference.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to