LogEventFilterpublic class LogEventFilter extends Object implements NotificationFilterThis is a NotificationFilter that will be instrumented to LogEvent to
filterout unwanted logEvents. Basically, it will filterout logs based on
LoggerName and Level settings. |
Fields Summary |
---|
private static com.sun.enterprise.util.i18n.StringManager | sm | private boolean | anyLogger | private ArrayList | loggerNames | private Level | level |
Constructors Summary |
---|
public LogEventFilter()Creates a new instance of LogNotificationFilter
|
Methods Summary |
---|
public java.lang.String | getLevel()
return level.toString();
| public java.util.List | getLoggerNames()
return loggerNames;
| public boolean | isNotificationEnabled(javax.management.Notification notification)
boolean loggerNameMatched = false;
boolean logLevelMatched = false;
if (anyLogger)
loggerNameMatched = true;
else {
String loggerNameFromNotification = (String)Util.getAMXNotificationValue(notification,
LogRecordEmitter.LOG_RECORD_LOGGER_NAME_KEY);
Iterator iterator = loggerNames.iterator( );
while( iterator.hasNext( ) ) {
String loggerNameFromList = (String) iterator.next( );
if( loggerNameFromNotification.startsWith( loggerNameFromList )) {
loggerNameMatched = true;
break;
}
}
}
Level logLevelFromNotification = (Level)Util.getAMXNotificationValue(notification,
LogRecordEmitter.LOG_RECORD_LEVEL_KEY);
if( logLevelFromNotification.intValue() >= this.level.intValue() ) {
logLevelMatched = true;
}
return loggerNameMatched && logLevelMatched;
| public void | setLevel(java.lang.String level)
this.level = Level.parse(level);
| public void | setLoggerNames(java.lang.String loggers)
if( loggers == null ){
return;
}
loggerNames = new ArrayList<String>( );
StringTokenizer tokenizer = new StringTokenizer(loggers, ",");
while( tokenizer.hasMoreTokens()) {
String loggerName = tokenizer.nextToken();
if ("*".equals(loggerName)) {
anyLogger = true;
loggerNames.add( loggerName );
return;
}
loggerNames.add( loggerName );
}
|
|