jwo.utils
Class OutputLogger

java.lang.Object
  extended by jwo.utils.OutputLogger

public class OutputLogger
extends Object

Allows standard output and standard error output to be redirected or copied to an arbitrary log file. Useful for recording detailed error/usage output, or for providing an output console available to the client program.

Version:
2.3, 4th October, 2007.
Author:
Jo Wood

Field Summary
static int STANDARD_ERR
          Indicates standard error stream.
static int STANDARD_OUT
          Indicates standard output stream.
 
Constructor Summary
OutputLogger()
          Redirects standard and error output to the default logger output.
OutputLogger(boolean isCopied)
          Redirects or copies standard and error output to the default logger output.
OutputLogger(Logger logger)
          Redirects standard and error output to the given logger.
OutputLogger(Logger logger, boolean isCopied)
          Redirects or copies standard and error output to the given logger.
 
Method Summary
 Logger getLogger()
          Reports the logger used to capture output.
static String getStackTraceAsString(Exception e)
          Reports a full stack trace as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD_OUT

public static final int STANDARD_OUT
Indicates standard output stream.

See Also:
Constant Field Values

STANDARD_ERR

public static final int STANDARD_ERR
Indicates standard error stream.

See Also:
Constant Field Values
Constructor Detail

OutputLogger

public OutputLogger()
Redirects standard and error output to the default logger output. Uses a default 'jwo.utils' logger.


OutputLogger

public OutputLogger(boolean isCopied)
Redirects or copies standard and error output to the default logger output. Uses a default 'jwo.utils' logger.

Parameters:
isCopied - Output will also be sent to stdout/stderr if true.

OutputLogger

public OutputLogger(Logger logger)
Redirects standard and error output to the given logger.

Parameters:
logger - Logger that will capture output.

OutputLogger

public OutputLogger(Logger logger,
                    boolean isCopied)
Redirects or copies standard and error output to the given logger.

Parameters:
logger - Logger that will capture output.
isCopied - Output will also be sent to stdout/stderr if true.
Method Detail

getStackTraceAsString

public static String getStackTraceAsString(Exception e)
Reports a full stack trace as a string. Useful for sending exception stack traces to the logger.

Parameters:
e - Exception to store.
Returns:
String holding full stack trace of exception.

getLogger

public Logger getLogger()
Reports the logger used to capture output.

Returns:
Logger used to capture output.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009