com.ibm.as400.ui.framework.java
Class MessageLog

java.lang.Object
  extended by com.ibm.as400.ui.framework.java.MessageLog

public class MessageLog
extends Object

Provides control over logging and tracing activity within this package. MessageLog can be used to redirect error logging to a specific log file or OutputStream. It's also used to suppress the low level information/error messages normally written to the console.

Since:
v4r2m0
Version:
1.0, 04/15/98
Author:
D. Petty

Method Summary
Modifier and Type Method and Description
static String getLogFileName()
          Returns the log file name.
static OutputStream getLogStream()
          Returns the log stream.
static boolean isTraceEnabled()
          Determines whether low level trace messages will be written to the console.
static void logError(Object errorData)
          Logs an error string to the current logging destination.
static void logError(Object errorData, Throwable throwable)
          Logs an error string and a stack trace to the current logging destination.
static void printStackTrace(Throwable throwable)
          Logs a stack trace to the current logging destination.
static void setLogFileName(String fileName)
          Sets the log file name.
static void setLogStream(OutputStream stream)
          Sets the log stream.
static void setTraceEnabled(boolean enabled)
          Controls whether low level trace messages will be written to the console.
static void traceErr(Object data)
          Writes data to System.err if low level tracing is enabled.
static void traceOut(Object data)
          Writes data to System.out if low level tracing is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLogFileName

public static void setLogFileName(String fileName)
                           throws IOException
Sets the log file name. If the file exists, error data is appended to it. If the file does not exist, it is created.

Parameters:
fileName - the log file name. If null, output goes to System.err.
Throws:
IOException - if the file cannot be accessed
Since:
v4r2m0
See Also:
getLogFileName()

getLogFileName

public static String getLogFileName()
Returns the log file name. Returns null if errors are being logged to System.err, or if an OutputStream was specified on a call to setLogStream.

Returns:
the log file name
Since:
v4r2m0
See Also:
setLogFileName(java.lang.String), setLogStream(java.io.OutputStream)

setLogStream

public static void setLogStream(OutputStream stream)
Sets the log stream. This method allows applications to redirect errors generated by this package to the same OutputStream used by the application itself for logging errors.

Parameters:
stream - the OutputStream to which error data should be sent. If null, output goes to System.err.
Since:
v4r2m0
See Also:
getLogStream()

getLogStream

public static OutputStream getLogStream()
Returns the log stream. This method is guaranteed to return a valid non-null OutputStream.

Returns:
the OutputStream to which error data is being sent
Since:
v4r2m0
See Also:
setLogStream(java.io.OutputStream)

logError

public static void logError(Object errorData)
Logs an error string to the current logging destination. The string will be prepended with a header containing a date and timestamp if logging has been redirected to a destination other than System.err.

Parameters:
errorData - the data to be logged
Since:
v4r2m0

logError

public static void logError(Object errorData,
                            Throwable throwable)
Logs an error string and a stack trace to the current logging destination. The string will be prepended with a header containing a date and timestamp if logging has been redirected to a destination other than System.err.

Parameters:
errorData - the data to be logged
throwable - the Throwable which will be used to obtain the stack trace
Since:
v4r2m0

printStackTrace

public static void printStackTrace(Throwable throwable)
Logs a stack trace to the current logging destination.

Parameters:
throwable - the Throwable which will be used to obtain the stack trace
Since:
v4r2m0

setTraceEnabled

public static void setTraceEnabled(boolean enabled)
Controls whether low level trace messages will be written to the console. The default value is true.

Parameters:
enabled - If true, allows the messages; otherwise, suppresses the messages.
Since:
v4r2m0
See Also:
isTraceEnabled()

isTraceEnabled

public static boolean isTraceEnabled()
Determines whether low level trace messages will be written to the console. The default value is true.

Returns:
true if the messages are allowed; false otherwise.
Since:
v4r2m0
See Also:
setTraceEnabled(boolean)

traceOut

public static void traceOut(Object data)
Writes data to System.out if low level tracing is enabled.

Parameters:
data - the data to be logged
Since:
v4r2m0
See Also:
traceErr(java.lang.Object)

traceErr

public static void traceErr(Object data)
Writes data to System.err if low level tracing is enabled.

Parameters:
data - the data to be logged
Since:
v4r2m0
See Also:
traceOut(java.lang.Object)