Search in sources :

Example 1 with ReconfigureOnChangeTask

use of ch.qos.logback.classic.joran.ReconfigureOnChangeTask in project cassandra by apache.

the class AggregationTest method configureLogbackScanPeriod.

private static void configureLogbackScanPeriod(long millis) {
    Logger l = LoggerFactory.getLogger(AggregationTest.class);
    ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) l;
    LoggerContext ctx = logbackLogger.getLoggerContext();
    TurboFilterList turboFilterList = ctx.getTurboFilterList();
    boolean done = false;
    for (TurboFilter turboFilter : turboFilterList) {
        if (turboFilter instanceof ReconfigureOnChangeFilter) {
            ReconfigureOnChangeFilter reconfigureFilter = (ReconfigureOnChangeFilter) turboFilter;
            reconfigureFilter.setContext(ctx);
            reconfigureFilter.setRefreshPeriod(millis);
            reconfigureFilter.stop();
            // start() sets the next check timestammp
            reconfigureFilter.start();
            done = true;
            break;
        }
    }
    ReconfigureOnChangeTask roct = (ReconfigureOnChangeTask) ctx.getObject(RECONFIGURE_ON_CHANGE_TASK);
    if (roct != null) {
        // Let the test run anyway, just we cannot reconfigure it (and it is pointless to reconfigure).
        return;
    }
    assertTrue("ReconfigureOnChangeFilter not in logback's turbo-filter list - do that by adding scan=\"true\" to logback-test.xml's configuration element", done);
}
Also used : ReconfigureOnChangeFilter(ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter) TurboFilterList(ch.qos.logback.classic.spi.TurboFilterList) ReconfigureOnChangeTask(ch.qos.logback.classic.joran.ReconfigureOnChangeTask) Logger(org.slf4j.Logger) LoggerContext(ch.qos.logback.classic.LoggerContext) TurboFilter(ch.qos.logback.classic.turbo.TurboFilter)

Aggregations

LoggerContext (ch.qos.logback.classic.LoggerContext)1 ReconfigureOnChangeTask (ch.qos.logback.classic.joran.ReconfigureOnChangeTask)1 TurboFilterList (ch.qos.logback.classic.spi.TurboFilterList)1 ReconfigureOnChangeFilter (ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter)1 TurboFilter (ch.qos.logback.classic.turbo.TurboFilter)1 Logger (org.slf4j.Logger)1