com.ibm.as400.access
Class EventLog

java.lang.Object
  extended by com.ibm.as400.access.EventLog
All Implemented Interfaces:
Log

public class EventLog
extends Object
implements Log

The EventLog class is an implementation of Log which logs exceptions and messages to the specified file or PrintStream.

Here is an example use of EventLog, which will write a timestamp and message to the specified file:

  EventLog myLog = new EventLog("myFile");
  myLog.log("You have successfully written to my log file.");
  myLog.log("Another log message.");
  

Each successive message will be appended to the previous messages in the log.

Here is what the log file will look like:

Mon Jan 03 09:00:00 CST 2000 Yout have successfully written to my log file.
Mon Jan 03 09:00:01 CST 2000 Another log message.


Constructor Summary
EventLog()
          Constructs a default EventLog object.
EventLog(OutputStream stream)
          Constructs an EventLog object with the specified OutputStream.
EventLog(PrintWriter out)
          Constructs an EventLog object with the specified PrintWriter.
EventLog(String pathname)
          Constructs an EventLog object with the specified file pathname.
 
Method Summary
protected  void finalize()
           
 void log(String msg)
          Logs a message to the event log.
 void log(String msg, Throwable exception)
          Logs an exception and message to the event log.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventLog

public EventLog()
Constructs a default EventLog object. Using this constructor, all log output will be sent to standard out.


EventLog

public EventLog(String pathname)
         throws IOException
Constructs an EventLog object with the specified file pathname. If a log file already exists with the specified pathname, all messages will be appended to the existing log file.

Parameters:
pathname - The file pathname.
Throws:
IOException - If an error occurs while accessing the file.

EventLog

public EventLog(OutputStream stream)
         throws IOException
Constructs an EventLog object with the specified OutputStream.

Parameters:
stream - The log OutputStream.
Throws:
IOException - If an error occurs while accessing the stream.

EventLog

public EventLog(PrintWriter out)
Constructs an EventLog object with the specified PrintWriter.

Parameters:
out - The PrintWriter.
Method Detail

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

log

public void log(String msg)
Logs a message to the event log. The log will contain a timestamp then the message.

Specified by:
log in interface Log
Parameters:
msg - The message to log.

log

public void log(String msg,
                Throwable exception)
Logs an exception and message to the event log. The log will contain a timestamp, the message, and then the exception stack trace.

Specified by:
log in interface Log
Parameters:
msg - The message to log.
exception - The exception to log.