com.ibm.as400.access

Class EventLog

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


    public class EventLog
    extends java.lang.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

      Constructors 
      Constructor and Description
      EventLog()
      Constructs a default EventLog object.
      EventLog(java.io.OutputStream stream)
      Constructs an EventLog object with the specified OutputStream.
      EventLog(java.io.PrintWriter out)
      Constructs an EventLog object with the specified PrintWriter.
      EventLog(java.lang.String pathname)
      Constructs an EventLog object with the specified file pathname.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      protected void finalize() 
      void log(java.lang.String msg)
      Logs a message to the event log.
      void log(java.lang.String msg, java.lang.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(java.lang.String pathname)
                 throws java.io.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:
        java.io.IOException - If an error occurs while accessing the file.
      • EventLog

        public EventLog(java.io.OutputStream stream)
                 throws java.io.IOException
        Constructs an EventLog object with the specified OutputStream.
        Parameters:
        stream - The log OutputStream.
        Throws:
        java.io.IOException - If an error occurs while accessing the stream.
      • EventLog

        public EventLog(java.io.PrintWriter out)
        Constructs an EventLog object with the specified PrintWriter.
        Parameters:
        out - The PrintWriter.
    • Method Detail

      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • log

        public void log(java.lang.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(java.lang.String msg,
               java.lang.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.