com.bowstreet.appserver.logmanager
Class LogEvent

java.lang.Object
  extended by com.bowstreet.appserver.logmanager.LogEvent

public class LogEvent
extends java.lang.Object

Users call the public static method of this class to log message.

Usage Notes:
In strings passed to any of the writeLogFormatted methods, single quotes can be used to quote the "{" (curly brace) if necessary. A real single quote is represented by ''. This is required by java.text.MessageFormat.

Author:
Bin Ji

Method Summary
static boolean okToWrite(int severity, int component)
          check if a specific combination of severity and component will be loged.
static void writeLogEntry(int severity, int component, java.lang.String msg)
          write an event log.
static void writeLogEntry(int severity, int component, java.lang.Throwable thr)
          This is a method to allow logging of exceptions and errors.
static void writeLogEntry(java.lang.String str)
          write an event log with severity=information and component=unknown.
static void writeLogEntryMsgWithThrowable(int severity, int component, java.lang.String msg, java.lang.Throwable thr)
          Log a message with an accompaning stack trace.
static void writeLogEntryResourceWithThrowable(int severity, int component, java.lang.String resourceId, java.lang.Throwable thr)
          Log a message identified by a resource id with an accompaning stack trace.
static void writeLogFormatted(int severity, int component, java.lang.String strID)
          write an event log.
static void writeLogFormatted(int severity, int component, java.lang.String strID, java.lang.Object arg1)
          A convenience method for writing a formatted message without instantiating a LogEvent object.
static void writeLogFormatted(int severity, int component, java.lang.String strID, java.lang.Object[] args)
          write an event log.
static void writeLogFormatted(int severity, int component, java.lang.String strID, java.lang.Object arg1, java.lang.Object arg2)
          A convenience method for writing a formatted message without instantiating a LogEvent object.
static void writeLogFormatted(int severity, int component, java.lang.String strID, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          A convenience method for writing a formatted message without instantiating a LogEvent object.
static void writeLogFormatted(int severity, int component, java.lang.String strID, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          A convenience method for writing a formatted message without instantiating a LogEvent object.
static void writeLogFormatted(int severity, int component, java.lang.String strID, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5)
          A convenience method for writing a formatted message without instantiating a LogEvent object.
static void writeLogFormatted(int severity, java.lang.String provider, int component, java.lang.String strID, java.lang.Object[] args, java.lang.Object logProducer, boolean isThreadNameRecorded)
          the most complete method for writing a formatted message without instantiating a LogEvent object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

okToWrite

public static boolean okToWrite(int severity,
                                int component)
check if a specific combination of severity and component will be loged. We want to call this method before we create expensive message or args

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
Returns:
true if a message with the combination of serverity and component will be logged.

writeLogEntry

public static void writeLogEntry(int severity,
                                 int component,
                                 java.lang.String msg)
write an event log.

Parameters:
severity - The severity associated with the event.
component - The component in which the event occurred.
msg - the message need to recorded.
See Also:
Severity, Component

writeLogEntry

public static void writeLogEntry(int severity,
                                 int component,
                                 java.lang.Throwable thr)
This is a method to allow logging of exceptions and errors. The exception stack trace is always logged.

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
thr - The Throwable object to be logged
See Also:
Severity, Component

writeLogEntry

public static void writeLogEntry(java.lang.String str)
write an event log with severity=information and component=unknown.


writeLogEntryMsgWithThrowable

public static void writeLogEntryMsgWithThrowable(int severity,
                                                 int component,
                                                 java.lang.String msg,
                                                 java.lang.Throwable thr)
Log a message with an accompaning stack trace.
 Format looks like:
    *-- TIME: [Fri Nov 17 11:05:11 EST 2000] --*
    Severity:   SEVERE
    Component:  ADMIN
    MSG:        "EventManager: error trimming event store
    Exception: com.bowstreet.util.xml.XmlDOMException: Not a child of node
    at com.bowstreet.util.xml.XmlElement.removeChild(XmlElement.java:381)
    ....
 

Parameters:
severity - The severity associated with the event.
component - The component in which the event occurred.
msg - String message that summarizes the error
thr - The Throwable object to be logged
See Also:
Severity, Component

writeLogEntryResourceWithThrowable

public static void writeLogEntryResourceWithThrowable(int severity,
                                                      int component,
                                                      java.lang.String resourceId,
                                                      java.lang.Throwable thr)
Log a message identified by a resource id with an accompaning stack trace.
 Format looks like:
    *-- TIME: [Fri Nov 17 11:05:11 EST 2000] --*
    Severity:   SEVERE
    Component:  ADMIN
    MSG:        "EventManager: error trimming event store
    Exception: com.bowstreet.util.xml.XmlDOMException: Not a child of node
    at com.bowstreet.util.xml.XmlElement.removeChild(XmlElement.java:381)
    ....
 

Parameters:
severity - The severity associated with the event.
component - The component in which the event occurred.
resourceId - resourceID identifies the msg text to be logged. resourceID must be found in the LogManagerBundle.properties.
thr - The Throwable object to be logged
See Also:
Severity, Component

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID)
write an event log.

Parameters:
severity - The severity associated with the event.
component - The component in which the event occurred.
strID - The key for the message in the resource bundle
See Also:
Severity, Component

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object arg1)
A convenience method for writing a formatted message without instantiating a LogEvent object. This method supports a formatted message that requires one argument.

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
strID - The key for the message in the resource bundle
arg1 - The argument the string needs for formatting
See Also:
Severity, Component, writeLogFormatted(int, int, String, Object[])

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object[] args)
write an event log.

Parameters:
severity - The severity associated with the event.
component - The component in which the event occurred.
strID - The key for the message in the resource bundle
args - Any arguments the string may need for formatting
See Also:
Severity, Component

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object arg1,
                                     java.lang.Object arg2)
A convenience method for writing a formatted message without instantiating a LogEvent object. This method supports a formatted message that requires two arguments.

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
strID - The key for the message in the resource bundle
arg1 - The arguments the string needs for formatting
arg2 - The arguments the string needs for formatting
See Also:
writeLogFormatted(long, String, Object[])

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object arg1,
                                     java.lang.Object arg2,
                                     java.lang.Object arg3)
A convenience method for writing a formatted message without instantiating a LogEvent object. This method supports a formatted message that requires three arguments.

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
strID - The key for the message in the resource bundle
arg1 - The arguments the string needs for formatting
arg2 - The arguments the string needs for formatting
arg3 - The arguments the string needs for formatting
See Also:
Severity, Component

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object arg1,
                                     java.lang.Object arg2,
                                     java.lang.Object arg3,
                                     java.lang.Object arg4)
A convenience method for writing a formatted message without instantiating a LogEvent object. This method supports a formatted message that requires four arguments.

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
strID - The key for the message in the resource bundle
arg1 - The arguments the string needs for formatting
arg2 - The arguments the string needs for formatting
arg3 - The arguments the string needs for formatting
arg4 - The arguments the string needs for formatting
See Also:
Severity, Component

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object arg1,
                                     java.lang.Object arg2,
                                     java.lang.Object arg3,
                                     java.lang.Object arg4,
                                     java.lang.Object arg5)
A convenience method for writing a formatted message without instantiating a LogEvent object. This method supports a formatted message that requires five arguments.

Parameters:
severity - The severity associated with the log event.
component - The component in which the log event occurred.
strID - The key for the message in the resource bundle
arg1 - The arguments the string needs for formatting
arg2 - The arguments the string needs for formatting
arg3 - The arguments the string needs for formatting
arg4 - The arguments the string needs for formatting
arg5 - The arguments the string needs for formatting
See Also:
writeLogFormatted(long, String, Object[])

writeLogFormatted

public static void writeLogFormatted(int severity,
                                     java.lang.String provider,
                                     int component,
                                     java.lang.String strID,
                                     java.lang.Object[] args,
                                     java.lang.Object logProducer,
                                     boolean isThreadNameRecorded)
the most complete method for writing a formatted message without instantiating a LogEvent object.

Parameters:
severity - The severity associated with the log event.
provider - provider of the component
component - The component in which the log event occurred.
strID - The key for the message in the resource bundle
args - Any arguments the string may need for formatting
logProducer - the producer of this log, usually pass a "this" reference.
isThreadNameRecorded - do you want to record the name of current thread
See Also:
Severity, Component


Copyright © 2009 IBM. All Rights Reserved.