Use the Java Logging API to Generate and Log Common Base Events

 

+

Search Tips   |   Advanced Search

 

In the WebSphere Application Server, the Java logging API (java.util.logging) automatically creates Common Base Events for events logged at level WsLevel.DETAIL or above (including WsLevel.DETAIL, Level.CONFIG, Level.INFO, WsLevel.AUDIT, Level.WARNING, Level.SEVERE, and WsLevel.FATAL). These Common Base Events are created using the event factory associated with the Logger to which the message was logged. If no event factory is specified, uses a default event factory which will automatically fill in specific information.

The java.util.logging.Logger class provides a variety of methods with which data can be logged. The uses a special implementation of the Logger class that automatically creates Common Base Events for the following methods:

  • config
  • info
  • warning
  • severe
  • log - all variants except log(LogRecord) when used with WsLevel.DETAIL or more severe levels
  • logp - when used with WsLevel.DETAIL or more severe levels
  • logrb - when used with WsLevel.DETAIL or more severe levels

logger implementation is only used for named loggers (for example, loggers instantiated with calls such as...

Logger.getLogger("com.xyz.SomeLoggerName"))

Loggers instantiated with calls to Logger.getAnonymousLogger() and Logger.getLogger(""), or Logger.global do not use the implementation, and do not automatically create Common Base Events for logging requests made to them. LogRecords logged directly with Logger.log(LogRecord) are not automatically converted by 's Loggers into Common Base Events.

The following diagram illustrates how application code can create log CommonBaseEvents:

The Java logging API processing of named Loggers and message level events proceeds as follows:

  1. Application code invokes named Logger (WsLevel.DETAIL or above) with event specific data.

  2. Logger creates a CommonBaseEvent using createCommonBaseEvent method on EventFactory associated to the Logger (see Configuring Common Base Events for an application).

  3. Logger creates a CommonBaseEvent using EventFactory associated to the Logger

  4. Logger wraps CommonBaseEvent in a CommonBaseEventLogRecord, and adds event specific data.

  5. Logger calls CommonBaseEvent's complete() method.

  6. CommonBaseEvent invokes ContentHandler's completeEvent() method.

  7. ContentHandler adds XML template data to CommonBaseEvent (including for example, the component name). Note that not all ContentHandlers support templates.

  8. ContentHandler adds runtime data to CommonBaseEvent (including for example, the current thread name).

  9. Logger passes CommonBaseEventLogRecord to Handlers.

  10. Handlers format data and write to Output Device.