Java Code Examples for ch.qos.logback.classic.LoggerContext#addTurboFilter()

The following examples show how to use ch.qos.logback.classic.LoggerContext#addTurboFilter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogbackLoggingConfigurer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void doConfigure(LogLevel logLevel) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    if (currentLevel == null) {
        context.reset();
        context.addTurboFilter(new GradleFilter());
        context.getLogger("org.apache.http.wire").setLevel(Level.OFF);
        context.getLogger("org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule").setLevel(Level.ERROR);
        GradleAppender appender = new GradleAppender();
        appender.setContext(context);
        appender.start();
        rootLogger.addAppender(appender);
    }

    currentLevel = logLevel;
    rootLogger.setLevel(LogLevelConverter.toLogbackLevel(logLevel));
}
 
Example 2
Source File: LogbackLoggingConfigurer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void doConfigure(LogLevel logLevel) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    if (currentLevel == null) {
        context.reset();
        context.addTurboFilter(new GradleFilter());
        context.getLogger("org.apache.http.wire").setLevel(Level.OFF);
        GradleAppender appender = new GradleAppender();
        appender.setContext(context);
        appender.start();
        rootLogger.addAppender(appender);
    }

    currentLevel = logLevel;
    rootLogger.setLevel(LogLevelConverter.toLogbackLevel(logLevel));
}
 
Example 3
Source File: LogbackLoggingSystemLauncherListener.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@Override
public void beforeStartup()
{
    _logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    if (!_logger.iteratorForAppenders().hasNext())
    {
        _logger.setLevel(Level.ALL);
        _logger.setAdditive(true);
    }

    final LoggerContext loggerContext = _logger.getLoggerContext();
    _logback1027WorkaroundTurboFilter = new Logback1027WorkaroundTurboFilter();
    loggerContext.addTurboFilter(_logback1027WorkaroundTurboFilter);

    _startupAppender = new StartupAppender();
    _startupAppender.setContext(loggerContext);
    _startupAppender.start();
    _logger.addAppender(_startupAppender);
}
 
Example 4
Source File: LogbackLoggingConfigurer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void doConfigure(LogLevel logLevel) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    if (currentLevel == null) {
        context.reset();
        context.addTurboFilter(new GradleFilter());
        context.getLogger("org.apache.http.wire").setLevel(Level.OFF);
        context.getLogger("org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule").setLevel(Level.ERROR);
        GradleAppender appender = new GradleAppender();
        appender.setContext(context);
        appender.start();
        rootLogger.addAppender(appender);
    }

    currentLevel = logLevel;
    rootLogger.setLevel(LogLevelConverter.toLogbackLevel(logLevel));
}
 
Example 5
Source File: LogbackLoggingConfigurer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void doConfigure(LogLevel logLevel) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    if (currentLevel == null) {
        context.reset();
        context.addTurboFilter(new GradleFilter());
        context.getLogger("org.apache.http.wire").setLevel(Level.OFF);
        GradleAppender appender = new GradleAppender();
        appender.setContext(context);
        appender.start();
        rootLogger.addAppender(appender);
    }

    currentLevel = logLevel;
    rootLogger.setLevel(LogLevelConverter.toLogbackLevel(logLevel));
}
 
Example 6
Source File: LoggingBootstrap.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes all Logging for HiveMQ. Call this method only once
 * at the very beginning of the HiveMQ lifecycle
 */
public static void initLogging(final @NotNull File configFolder) {

    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    final ch.qos.logback.classic.Logger logger = getRootLogger();

    context.addListener(new LogbackChangeListener(logger));

    final boolean overridden = overrideLogbackXml(configFolder);

    if (!overridden) {
        reEnableDefaultAppenders();
    }
    redirectJULToSLF4J();
    logQueuedEntries();

    reset();

    // must be added here, as addLoglevelModifiers() is much to late
    if (SystemUtils.IS_OS_WINDOWS) {
        context.addTurboFilter(xodusFileDataWriterLogLevelModificator);
        log.trace("Added Xodus log level modifier for FileDataWriter.class");
    }

    context.addTurboFilter(nettyLogLevelModifier);
    log.trace("Added Netty log level modifier");
}
 
Example 7
Source File: XodusEnvironmentImplLogLevelModificatorTest.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

    rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    level = rootLogger.getLevel();
    rootLogger.setLevel(Level.TRACE);
    context.addTurboFilter(new XodusEnvironmentImplLogLevelModificator());
    context.getLogger("jetbrains.exodus").setLevel(Level.TRACE);
}
 
Example 8
Source File: XodusFileDataWriterLogLevelModificatorSingularityTest.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    context = (LoggerContext) LoggerFactory.getILoggerFactory();

    rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    level = rootLogger.getLevel();
    rootLogger.setLevel(Level.DEBUG);
    context.addTurboFilter(new XodusFileDataWriterLogLevelModificator());
    context.getLogger("jetbrains.exodus").setLevel(Level.DEBUG);
}
 
Example 9
Source File: XodusFileDataWriterLogLevelModificatorTest.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    context = (LoggerContext) LoggerFactory.getILoggerFactory();

    rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    level = rootLogger.getLevel();
    rootLogger.setLevel(Level.DEBUG);
    context.addTurboFilter(new XodusFileDataWriterLogLevelModificator());
    context.getLogger("jetbrains.exodus").setLevel(Level.DEBUG);
}
 
Example 10
Source File: DefaultLogbackReInitializer.java    From sofa-common-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void reInitialize(final SpaceId spaceId, LoggerContext loggerContext,
                         final Properties properties, URL confFile) {
    if (isAlreadyReInitialized(loggerContext)) {
        return;
    }
    stopAndReset(loggerContext);
    loggerContext.getTurboFilterList().remove(DefaultLogbackFilterGenerator.FILTER);
    markAsReInitialized(loggerContext);
    initProperties(loggerContext, properties);
    if (isConsoleAppenderOpen(spaceId.getSpaceName(), properties)) {
        final ConsoleAppender appender = consoleAppender(loggerContext, properties);
        loggerContext.addTurboFilter(new TurboFilter() {
            @Override
            public FilterReply decide(Marker marker, Logger logger, Level level, String format,
                                      Object[] params, Throwable t) {
                if (!logger.isAttached(appender)) {
                    logger.detachAndStopAllAppenders();
                    logger.setLevel(getConsoleLevel(spaceId.getSpaceName(), properties));
                    logger.addAppender(appender);
                }
                return FilterReply.NEUTRAL;
            }
        });
    } else {
        try {
            new ContextInitializer(loggerContext).configureByResource(confFile);
        } catch (JoranException e) {
            throw new IllegalStateException("Logback loggerSpaceFactory re-build error", e);
        }
    }

}
 
Example 11
Source File: LoggingBootstrap.java    From hivemq-community-edition with Apache License 2.0 4 votes vote down vote up
public static void addLoglevelModifiers() {
    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

    context.addTurboFilter(xodusEnvironmentImplLogLevelModificator);
    log.trace("Added Xodus log level modifier for EnvironmentImpl.class");
}
 
Example 12
Source File: LoggingBootstrap.java    From hivemq-community-edition with Apache License 2.0 4 votes vote down vote up
private void addTurboFilters(final @NotNull LoggerContext context) {

            context.addTurboFilter(xodusFileDataWriterLogLevelModificator);
            context.addTurboFilter(nettyLogLevelModifier);
            context.addTurboFilter(xodusEnvironmentImplLogLevelModificator);
        }