On Jun 20, 2007, at 12:09 PM, Thorsten Möller wrote:
Hello,
I'm using Log4J combined with Apache commons.logging in my
application and
want to capture everything that is written to System.out to a SWING
text
area component. This means the "flow" would be as follows.
Somewhere in the code there are usual logging statements:
logger.info("foo");
Via commons.logging those statements will be forwarded to a Log4J
org.apache.log4j.ConsoleAppender which in turn has its target set to
System.out (so far this is all configured properly an works nice).
Then, the SWING application re-assigns System.out print stream by
invoking
System.setOut(myPrintStream) - "myPrintStream" does nothing more
than to
append to an JTextArea. The result is that nothing will be printed to
"myPrintStream" by the logging statements.
It seems to me that the re-assignment System.setOut(..) happens
just too
late after Log4J has
configured everything already, i.e., it still writes to the "old"
print
stream that was assigned before. If I'm right then there would be no
solution to achieve what I want to achieve. Does anybody konws of
another
way to achieve this.
Many thanks,
Thorsten
Use log4j-1.2.14 (or later) and specify follow=true in your
configuration of your console appender and it will follow subsequent
redirections of System.out. See bugs 31056 and 37122.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]