FileDocCategorySizeDatePackage
LogEventFilter.javaAPI DocGlassfish v2 API5164Fri May 04 22:33:44 BST 2007com.sun.enterprise.admin.selfmanagement.event

LogEventFilter

public class LogEventFilter extends Object implements NotificationFilter
This is a NotificationFilter that will be instrumented to LogEvent to filterout unwanted logEvents. Basically, it will filterout logs based on LoggerName and Level settings.
author
Sun Micro Systems, Inc

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.StringgetLevel()

        return level.toString();
    
public java.util.ListgetLoggerNames()

        return loggerNames;
    
public booleanisNotificationEnabled(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 voidsetLevel(java.lang.String level)

        this.level = Level.parse(level);
    
public voidsetLoggerNames(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 );
        }