In a Java/Swing application we redirected System.out and System.err to a separate view (called "SystemOutView") which pops open when a new output occurs. This works fine for thrown exceptions and System.out.println()
. This view can be configured via a property file (i.e. if it is active at all and if it pops open on output or not).
In this project we are using log4j 1.2.15. I found that the log4j outputs, even though sent to STDOUT, are NOT being redirected to the SystemOutView if some logging already took place BEFORE the SystemOutView was instantiated and System.out and System.err were redirected to it.
In other words:
- Redirect System.out and System.err to SystemOutView
- someLogger.debug("...")
... works fine: The log appears in the SystemOutView.
BUT:
- someLogger.debug("...")
- Redirect System.out and System.err to SystemOutView
- someLogger.debug("...")
... does NOT work: the 2nd log statement goes to STDOUT (like the 1st one) and is NOT being redirected to SystemOutView.
Since the SystemOutView can be configured via a property file, there is a whole bunch of work being done before SystemOutView gets instantiated, so it's very likely that some log statements are being issued. Which makes it impossible then to redirect the log output to the SystemOutView.
What can I do about that?
Many thanx in advance
:-Denis