FileDocCategorySizeDatePackage
SystemOutandErrHandler.javaAPI DocGlassfish v2 API15181Fri May 04 22:35:44 BST 2007com.sun.enterprise.server.logging

SystemOutandErrHandler

public class SystemOutandErrHandler extends Object
Class SystemOutandErrHandler extends PrintStream & is for use within the Application Server. The init is called from PEMain and this creates 2 instances of this class - one for Err & other for Out. This is not expected to be performance intensive and hence more defensive programming is done to reduce risk.

Fields Summary
private static final String
SYSTEMERR_LOGGER
private static final String
SYSTEMOUT_LOGGER
private static PrintStream
originalSystemErr
private static Logger
soLogger
private static Logger
seLogger
private static Level
errLogLevel
private static Level
outLogLevel
private static String
lineSeparator
private static int
lineSeparatorSize
private LoggingPrintStream
lout
private LoggingPrintStream
lerr
Constructors Summary
public SystemOutandErrHandler()


	  
	    if (originalSystemErr != null) {
		RuntimeException e = new RuntimeException("recursivecall");
                originalSystemErr.println("recursive call into SystemOutandErrhandler");
                e.printStackTrace(originalSystemErr);
		return;
	    }

	    LoggingByteArrayOutputStream buf = new LoggingByteArrayOutputStream();
	    // Initialise logger and set new systemout
	    seLogger = java.util.logging.Logger.getLogger(SYSTEMERR_LOGGER);
	    // seLogger = LogDomains.getLogger(LogDomains.SYSTEMERR_LOGGER, false);
	    buf.setLogger(seLogger, errLogLevel);
            originalSystemErr = System.err;
	    lerr = (new LoggingPrintStream(buf));
            lerr.setLogger(seLogger);
	    System.setErr(lerr);

	    buf = new LoggingByteArrayOutputStream();
	    // Initialise logger and set new systemout
	    soLogger = java.util.logging.Logger.getLogger(SYSTEMOUT_LOGGER);
	    buf.setLogger(soLogger, outLogLevel);
	    lout = (new LoggingPrintStream(buf));
            lout.setLogger(soLogger);
	    System.setOut(lout);

	    lineSeparator = (String) java.security.AccessController.doPrivileged(
		new sun.security.action.GetPropertyAction("line.separator"));
	    lineSeparatorSize = lineSeparator.length();

	
Methods Summary