Search in sources :

Example 1 with LoggingConfig

use of com.spotify.helios.common.LoggingConfig in project helios by spotify.

the class SentryTest method testSentryAppender.

@Test
public void testSentryAppender() throws Exception {
    // start our UDP server which will receive sentry messages
    final UdpServer udpServer = new UdpServer(sentryPort);
    // turn on logging which enables the sentry appender
    final LoggingConfig config = new LoggingConfig(0, true, null, false);
    ServiceMain.setupLogging(config, testDsn);
    // log a message at error level so sentry appender sends it to UDP server
    log.error("Ignore test message printed by Helios SentryTest");
    // be nice and turn logging back off
    LoggingConfigurator.configureNoLogging();
    // make sure we got the message as expected, note that getMessage is a blocking method
    final String message = udpServer.getMessage();
    assertTrue("Expected message beginning with 'Sentry', instead got " + message, message.startsWith("Sentry"));
}
Also used : LoggingConfig(com.spotify.helios.common.LoggingConfig) Test(org.junit.Test)

Example 2 with LoggingConfig

use of com.spotify.helios.common.LoggingConfig 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)

Aggregations

LoggingConfig (com.spotify.helios.common.LoggingConfig)2 Level (ch.qos.logback.classic.Level)1 Logger (ch.qos.logback.classic.Logger)1 Test (org.junit.Test)1