Search in sources :

Example 31 with Filter

use of org.apache.log4j.spi.Filter in project SSM by Intel-bigdata.

the class HeliumVisualizationFactory method configureLogger.

private void configureLogger() {
    org.apache.log4j.Logger npmLogger = org.apache.log4j.Logger.getLogger("com.github.eirslett.maven.plugins.frontend.lib.DefaultNpmRunner");
    Enumeration appenders = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
    if (appenders != null) {
        while (appenders.hasMoreElements()) {
            Appender appender = (Appender) appenders.nextElement();
            appender.addFilter(new Filter() {

                @Override
                public int decide(LoggingEvent loggingEvent) {
                    if (loggingEvent.getLoggerName().contains("DefaultNpmRunner")) {
                        return DENY;
                    } else {
                        return NEUTRAL;
                    }
                }
            });
        }
    }
    npmLogger.addAppender(new WriterAppender(new PatternLayout("%m%n"), out));
}
Also used : Appender(org.apache.log4j.Appender) WriterAppender(org.apache.log4j.WriterAppender) LoggingEvent(org.apache.log4j.spi.LoggingEvent) Filter(org.apache.log4j.spi.Filter) PatternLayout(org.apache.log4j.PatternLayout) WriterAppender(org.apache.log4j.WriterAppender)

Aggregations

Filter (org.apache.log4j.spi.Filter)31 Appender (org.apache.log4j.Appender)14 Layout (org.apache.log4j.Layout)9 LoggingEvent (org.apache.log4j.spi.LoggingEvent)7 ArrayList (java.util.ArrayList)5 WriterAppender (org.apache.log4j.WriterAppender)5 Enumeration (java.util.Enumeration)4 List (java.util.List)4 Logger (org.apache.log4j.Logger)4 FileAppender (org.apache.log4j.FileAppender)3 PatternLayout (org.apache.log4j.PatternLayout)3 FilterWrapper (org.apache.log4j.bridge.FilterWrapper)3 PropertySetter (org.apache.log4j.config.PropertySetter)3 ErrorHandler (org.apache.log4j.spi.ErrorHandler)3 LevelMatchFilter (org.apache.log4j.varia.LevelMatchFilter)3 LevelRangeFilter (org.apache.log4j.varia.LevelRangeFilter)3 NullAppender (org.apache.log4j.varia.NullAppender)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2