Class ConsoleRedirector
java.lang.Object
com.iizix.log.ConsoleRedirector
Class to handle redirection of stdout and stderr to the logger.
- Author:
- Christopher Mindus
Method Summary
Modifier and TypeMethodDescriptionstatic PrintStreamGets the real System.err from before it was redirected from the system, i.e.static PrintStream[]Starts the redirection of System.out and System.err.
Method Details
intialize
Starts the redirection of System.out and System.err.- Returns:
- Array of length 2 original output streams, index 0 = stdout, 1 = stderr.
- Throws:
IllegalStateException- If this has already been done.SecurityException- If a security manager exists and itscheckPermissionmethod doesn't allow reassigning of the standard output or error output stream.
getRealStdErr
Gets the real System.err from before it was redirected from the system, i.e. the stream that bypasses the redirection into the loggers.The saved stream is answered only while this class' own redirecting stream is the one currently installed as
System.err. If the redirection was never started, has been shut down, or someone else has replacedSystem.errsince, there is no redirection of ours left to bypass:nullis answered so the caller writes to the currentSystem.errrather than to a stale stream captured once, process wide, at class initialization.- Returns:
- The real System.err, or null when this class is not the redirection currently installed as
System.err.