FileDocCategorySizeDatePackage
LogRecordEmitter.javaAPI DocGlassfish v2 API9020Fri May 04 22:30:50 BST 2007com.sun.appserv.management.ext.logging

LogRecordEmitter

public interface LogRecordEmitter implements NotificationEmitter, com.sun.appserv.management.base.ListenerInfo
Emits {@link LogRecord} as JMX {@link Notification}.

The {@link LogRecord} is embedded within a Notification as follows: notif.getType() => a Notification type beginning with {@link #LOG_RECORD_NOTIFICATION_PREFIX}
notif.getSource() => ObjectName of {@link Logging} MBean that emitted the Notification notif.getUserData() => Map<String,Object> with keys as described below.

To avoid deserialization problems, an actual {@link LogRecord} is not transmitted. Instead, its important fields are extracted and placed into a Map obtained as follows:


final Map fields = (Map)notif.getUserData();
Alternately, you may use {@link Util#getAMXNotificationValue} to extract any] particular field.

Valid keys within the Map are:

  • {@link #LOG_RECORD_AS_STRING_KEY} value is the String version of the entire LogRecord

Here is an example of how to retrieve the LogRecord information when a Notification is received:

final Notifcation notif = ;
final String type = notif.getType();
final LogRecord logRecord = (LogRecord){@link Util#getAMXNotificationValue}( notif, LOG_RECORD_KEY );
final String logRecordString = (String){@link Util#getAMXNotificationValue}( notif, LOG_RECORD_STRING_KEY );
since
AS 9.0

Fields Summary
public static final String
LOG_RECORD_NOTIFICATION_PREFIX
Notification type prefix for a LogRecord Notification
public static final String
LOG_RECORD_SEVERE_NOTIFICATION_TYPE
Notification type for a SEVERE LogRecord
public static final String
LOG_RECORD_WARNING_NOTIFICATION_TYPE
Notification type for a WARNING LogRecord
public static final String
LOG_RECORD_INFO_NOTIFICATION_TYPE
Notification type for an INFO LogRecord
public static final String
LOG_RECORD_CONFIG_NOTIFICATION_TYPE
Notification type for a CONFIG LogRecord
public static final String
LOG_RECORD_FINE_NOTIFICATION_TYPE
Notification type for a FINE LogRecord
public static final String
LOG_RECORD_FINER_NOTIFICATION_TYPE
Notification type for a FINER LogRecord
public static final String
LOG_RECORD_FINEST_NOTIFICATION_TYPE
Notification type for a FINEST LogRecord
public static final String
LOG_RECORD_OTHER_NOTIFICATION_TYPE
Notification type for any other level eg a specific level number not equivalent to any of the standard ones
public static final Set
ALL_LOG_RECORD_NOTIFICATION_TYPES
public static final String
LOG_RECORD_KEY_PREFIX
All keys within the Map found in Notification.getUserData() have this prefix.
public static final String
LOG_RECORD_AS_STRING_KEY
Key to access the string representation of the {@link java.util.logging.LogRecord}. This value will always be present and non-null. Use {@link com.sun.appserv.management.base.Util#getAMXNotificationValue}(LOG_RECORD_STRING_KEY) to obtain this value.
public static final String
LOG_RECORD_LEVEL_KEY
value: Level
public static final String
LOG_RECORD_LOGGER_NAME_KEY
value: String
public static final String
LOG_RECORD_MESSAGE_KEY
value: String
public static final String
LOG_RECORD_MILLIS_KEY
value: Long
public static final String
LOG_RECORD_SEQUENCE_NUMBER_KEY
value: Long
public static final String
LOG_RECORD_SOURCE_CLASS_NAME_KEY
value: String
public static final String
LOG_RECORD_SOURCE_METHOD_NAME_KEY
value: String
public static final String
LOG_RECORD_THREAD_ID_KEY
value: Integer
public static final String
LOG_RECORD_THROWN_KEY
value: Throwable

All Throwables are remapped to standard java exceptions; the value will be a Throwable, but it may not be the original Throwable as thrown on the server side.

If nothing was thrown this key will not be found in the Map.

public static final String
LOG_RECORD_ROOT_CAUSE_KEY
value: Throwable

If LogRecord.getThrown() was non-null, this value is the innermost Throwable eg the root cause found by following Throwable.getCause() until the innermost Throwable is reached.

If the root cause is the same as the thrown exception, then this value will not exist.

Constructors Summary
Methods Summary
public intgetLogLevelListenerCount(java.util.logging.Level logLevel)
Get the number of listeners for the specified log level.

param
logLevel
return
number of listeners listening for messages of the specified level, or higher level