Search in sources :

Example 86 with Logger

use of ch.qos.logback.classic.Logger in project helios by spotify.

the class CliMain method setupLogging.

private void setupLogging() {
    final LoggingConfig config = parser.getLoggingConfig();
    if (config.getNoLogSetup()) {
        return;
    }
    final int verbose = config.getVerbosity();
    final Level level = get(asList(WARN, INFO, DEBUG, ALL), verbose, ALL);
    final Logger rootLogger = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);
    rootLogger.setLevel(level);
}
Also used : LoggingConfig(com.spotify.helios.common.LoggingConfig) Level(ch.qos.logback.classic.Level) Logger(ch.qos.logback.classic.Logger)

Example 87 with Logger

use of ch.qos.logback.classic.Logger in project spring-boot by spring-projects.

the class LogbackLoggingSystemTests method systemLevelTraceShouldReturnNativeLevelTraceNotAll.

@Test
public void systemLevelTraceShouldReturnNativeLevelTraceNotAll() throws Exception {
    this.loggingSystem.beforeInitialize();
    this.loggingSystem.initialize(this.initializationContext, null, null);
    this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.TRACE);
    Logger logger = this.loggingSystem.getLogger(getClass().getName());
    assertThat(logger.getLevel()).isEqualTo(Level.TRACE);
}
Also used : Logger(ch.qos.logback.classic.Logger) Test(org.junit.Test)

Example 88 with Logger

use of ch.qos.logback.classic.Logger in project spring-boot by spring-projects.

the class LogbackLoggingSystemTests method getLoggingConfigurationForALL.

@Test
public void getLoggingConfigurationForALL() throws Exception {
    this.loggingSystem.beforeInitialize();
    this.loggingSystem.initialize(this.initializationContext, null, null);
    Logger logger = this.loggingSystem.getLogger(getClass().getName());
    logger.setLevel(Level.ALL);
    LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration(getClass().getName());
    assertThat(configuration).isEqualTo(new LoggerConfiguration(getClass().getName(), LogLevel.TRACE, LogLevel.TRACE));
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) Logger(ch.qos.logback.classic.Logger) Test(org.junit.Test)

Example 89 with Logger

use of ch.qos.logback.classic.Logger in project spring-boot by spring-projects.

the class LogbackLoggingSystemTests method testBasicConfigLocation.

@Test
public void testBasicConfigLocation() throws Exception {
    this.loggingSystem.beforeInitialize();
    ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
    LoggerContext context = (LoggerContext) factory;
    Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    assertThat(root.getAppender("CONSOLE")).isNotNull();
}
Also used : ILoggerFactory(org.slf4j.ILoggerFactory) Logger(ch.qos.logback.classic.Logger) LoggerContext(ch.qos.logback.classic.LoggerContext) Test(org.junit.Test)

Example 90 with Logger

use of ch.qos.logback.classic.Logger in project sonarqube by SonarSource.

the class CeProcessLoggingTest method startup_logger_prints_to_only_to_system_out.

@Test
public void startup_logger_prints_to_only_to_system_out() {
    LoggerContext ctx = underTest.configure(props);
    Logger startup = ctx.getLogger("startup");
    assertThat(startup.isAdditive()).isFalse();
    Appender appender = startup.getAppender("CONSOLE");
    assertThat(appender).isInstanceOf(ConsoleAppender.class);
    ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) appender;
    assertThat(consoleAppender.getTarget()).isEqualTo("System.out");
    assertThat(consoleAppender.getEncoder()).isInstanceOf(PatternLayoutEncoder.class);
    PatternLayoutEncoder patternEncoder = (PatternLayoutEncoder) consoleAppender.getEncoder();
    assertThat(patternEncoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level app[][%logger{20}] %msg%n");
}
Also used : ConsoleAppender(ch.qos.logback.core.ConsoleAppender) FileAppender(ch.qos.logback.core.FileAppender) Appender(ch.qos.logback.core.Appender) ConsoleAppender(ch.qos.logback.core.ConsoleAppender) PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext) Test(org.junit.Test)

Aggregations

Logger (ch.qos.logback.classic.Logger)144 Test (org.junit.Test)49 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)45 LoggerContext (ch.qos.logback.classic.LoggerContext)40 FileAppender (ch.qos.logback.core.FileAppender)17 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)16 Appender (ch.qos.logback.core.Appender)16 File (java.io.File)13 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)12 ArrayList (java.util.ArrayList)9 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)8 AsyncLoggingEventAppenderFactory (io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory)8 DropwizardLayoutFactory (io.dropwizard.logging.layout.DropwizardLayoutFactory)7 Before (org.junit.Before)7 PipeConfiguration (co.cask.cdap.filetailer.config.PipeConfiguration)6 Query (org.apache.lucene.search.Query)6 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)6 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)6 Level (ch.qos.logback.classic.Level)5 Map (java.util.Map)5