Search in sources :

Example 1 with RootLoggerConfig

use of org.sonar.process.logging.RootLoggerConfig in project sonarqube by SonarSource.

the class SearchLogging method configure.

public LoggerContext configure(Props props) {
    LoggerContext ctx = helper.getRootContext();
    ctx.reset();
    RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(ProcessId.ELASTICSEARCH).build();
    String logPattern = helper.buildLogPattern(config);
    helper.configureGlobalFileLog(props, config, logPattern);
    helper.configureForSubprocessGobbler(props, logPattern);
    helper.apply(LogLevelConfig.newBuilder().rootLevelFor(ProcessId.ELASTICSEARCH).build(), props);
    return ctx;
}
Also used : RootLoggerConfig(org.sonar.process.logging.RootLoggerConfig) LoggerContext(ch.qos.logback.classic.LoggerContext)

Example 2 with RootLoggerConfig

use of org.sonar.process.logging.RootLoggerConfig in project sonarqube by SonarSource.

the class ServerProcessLogging method configureRootLogger.

private void configureRootLogger(Props props) {
    RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(processId).setThreadIdFieldPattern(threadIdFieldPattern).build();
    String logPattern = helper.buildLogPattern(config);
    helper.configureGlobalFileLog(props, config, logPattern);
    helper.configureForSubprocessGobbler(props, logPattern);
}
Also used : RootLoggerConfig(org.sonar.process.logging.RootLoggerConfig)

Example 3 with RootLoggerConfig

use of org.sonar.process.logging.RootLoggerConfig in project sonarqube by SonarSource.

the class ServerProcessLogging method configureDirectToConsoleLoggers.

/**
   * Setup one or more specified loggers to be non additive and to print to System.out which will be caught by the Main
   * Process and written to sonar.log.
   */
private void configureDirectToConsoleLoggers(LoggerContext context, String... loggerNames) {
    RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(ProcessId.APP).setThreadIdFieldPattern("").build();
    String logPattern = helper.buildLogPattern(config);
    ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", logPattern);
    for (String loggerName : loggerNames) {
        Logger consoleLogger = context.getLogger(loggerName);
        consoleLogger.setAdditive(false);
        consoleLogger.addAppender(consoleAppender);
    }
}
Also used : RootLoggerConfig(org.sonar.process.logging.RootLoggerConfig) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Logger(ch.qos.logback.classic.Logger)

Example 4 with RootLoggerConfig

use of org.sonar.process.logging.RootLoggerConfig in project sonarqube by SonarSource.

the class ServerProcessLogging method configureRootLogger.

private void configureRootLogger(Props props) {
    RootLoggerConfig config = newRootLoggerConfigBuilder().setProcessId(processId).setNodeNameField(getNodeNameWhenCluster(props)).setThreadIdFieldPattern(threadIdFieldPattern).build();
    Encoder<ILoggingEvent> encoder = helper.createEncoder(props, config, helper.getRootContext());
    helper.configureGlobalFileLog(props, config, encoder);
    helper.configureForSubprocessGobbler(props, encoder);
}
Also used : RootLoggerConfig(org.sonar.process.logging.RootLoggerConfig) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 5 with RootLoggerConfig

use of org.sonar.process.logging.RootLoggerConfig in project sonarqube by SonarSource.

the class ServerProcessLogging method configureDirectToConsoleLoggers.

/**
 * Setup one or more specified loggers to be non additive and to print to System.out which will be caught by the Main
 * Process and written to sonar.log.
 */
private void configureDirectToConsoleLoggers(Props props, LoggerContext context, String... loggerNames) {
    RootLoggerConfig config = newRootLoggerConfigBuilder().setNodeNameField(getNodeNameWhenCluster(props)).setProcessId(ProcessId.APP).setThreadIdFieldPattern("").build();
    Encoder<ILoggingEvent> encoder = helper.createEncoder(props, config, context);
    ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(context, "CONSOLE", encoder);
    for (String loggerName : loggerNames) {
        Logger consoleLogger = context.getLogger(loggerName);
        consoleLogger.setAdditive(false);
        consoleLogger.addAppender(consoleAppender);
    }
}
Also used : RootLoggerConfig(org.sonar.process.logging.RootLoggerConfig) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Logger(ch.qos.logback.classic.Logger)

Aggregations

RootLoggerConfig (org.sonar.process.logging.RootLoggerConfig)6 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)3 Logger (ch.qos.logback.classic.Logger)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 Log4JPropertiesBuilder (org.sonar.process.logging.Log4JPropertiesBuilder)1