com.ibm.as400.access

Class 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 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

      • 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.