Search in sources :

Example 16 with Logger

use of ch.qos.logback.classic.Logger in project Alpha by alpha-asp.

the class SolverTests method enableDebugLog.

private static void enableDebugLog() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.DEBUG);
}
Also used : Logger(ch.qos.logback.classic.Logger)

Example 17 with Logger

use of ch.qos.logback.classic.Logger in project Alpha by alpha-asp.

the class SolverTests method enableTracing.

/**
	 * Sets the logging level to TRACE. Useful for debugging; call at beginning of test case.
	 */
private static void enableTracing() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(ch.qos.logback.classic.Level.TRACE);
}
Also used : Logger(ch.qos.logback.classic.Logger)

Example 18 with Logger

use of ch.qos.logback.classic.Logger in project sling by apache.

the class ITAppenderServices method testOsgiAppenderRef.

@Test
public void testOsgiAppenderRef() throws Exception {
    Configuration config = ca.getConfiguration(ITConfigAdminSupport.PID, null);
    Dictionary<String, Object> p = new Hashtable<String, Object>();
    p.put(ITConfigAdminSupport.LOG_LEVEL, "INFO");
    p.put(ITConfigAdminSupport.LOGBACK_FILE, absolutePath("test-osg-appender-ref-config.xml"));
    config.update(p);
    delay();
    Logger ref = (Logger) LoggerFactory.getLogger("foo.ref.osgi");
    assertTrue(ref.isDebugEnabled());
    TestAppender ta = registerAppender("foo.bar", "foo.baz");
    delay();
    Logger bar = (Logger) LoggerFactory.getLogger("foo.bar");
    bar.setLevel(Level.DEBUG);
    Logger baz = (Logger) LoggerFactory.getLogger("foo.baz");
    baz.setLevel(Level.INFO);
    bar.debug("Test message");
    // Would not be logged
    baz.debug("Test message");
    ref.debug("Test message ref");
    // One event should be logged.
    assertEquals(2, ta.events.size());
}
Also used : Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable) Logger(ch.qos.logback.classic.Logger) Test(org.junit.Test)

Example 19 with Logger

use of ch.qos.logback.classic.Logger in project sling by apache.

the class ITAppenderServices method testAppenderService.

@Test
public void testAppenderService() throws Exception {
    TestAppender ta = registerAppender("foo.bar", "foo.baz");
    delay();
    Logger bar = (Logger) LoggerFactory.getLogger("foo.bar");
    bar.setLevel(Level.DEBUG);
    Logger baz = (Logger) LoggerFactory.getLogger("foo.baz");
    baz.setLevel(Level.INFO);
    bar.debug("Test message");
    // Would not be logged
    baz.debug("Test message");
    // One event should be logged.
    assertEquals(1, ta.events.size());
}
Also used : Logger(ch.qos.logback.classic.Logger) Test(org.junit.Test)

Example 20 with Logger

use of ch.qos.logback.classic.Logger in project sling by apache.

the class AppenderTracker method detachAppender.

private void detachAppender(final AppenderInfo ai) {
    if (ai != null) {
        for (final String name : ai.getLoggers()) {
            final Logger logger = loggerContext.getLogger(name);
            logger.detachAppender(ai.appender);
        }
        ai.appender.stop();
    }
}
Also used : Logger(ch.qos.logback.classic.Logger)

Aggregations

Logger (ch.qos.logback.classic.Logger)339 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)90 LoggerContext (ch.qos.logback.classic.LoggerContext)86 Test (org.junit.Test)78 Appender (ch.qos.logback.core.Appender)30 BeforeClass (org.junit.BeforeClass)28 FileAppender (ch.qos.logback.core.FileAppender)27 Test (org.junit.jupiter.api.Test)27 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)22 File (java.io.File)21 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)20 Level (ch.qos.logback.classic.Level)18 ListAppender (ch.qos.logback.core.read.ListAppender)14 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)12 ArrayList (java.util.ArrayList)11 Before (org.junit.Before)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 Map (java.util.Map)10 AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)9 DropwizardLayoutFactory (io.dropwizard.logging.layout.DropwizardLayoutFactory)8