use of ch.qos.logback.classic.Logger in project sonarqube by SonarSource.
the class AppLogging method configureRootWithLogbackWritingToFile.
private void configureRootWithLogbackWritingToFile(LoggerContext ctx) {
Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME);
String appLogPattern = helper.buildLogPattern(APP_ROOT_LOGGER_CONFIG);
FileAppender<ILoggingEvent> fileAppender = helper.newFileAppender(ctx, appSettings.getProps(), APP_ROOT_LOGGER_CONFIG, appLogPattern);
rootLogger.addAppender(fileAppender);
rootLogger.addAppender(createAppConsoleAppender(ctx, appLogPattern));
}
use of ch.qos.logback.classic.Logger in project sonarqube by SonarSource.
the class LogbackHelper method configureGlobalFileLog.
/**
* Make logback configuration for a process to push all its logs to a log file.
* <p>
* <ul>
* <li>the file's name will use the prefix defined in {@link RootLoggerConfig#getProcessId()#getLogFilenamePrefix()}.</li>
* <li>the file will follow the rotation policy defined in property {@link #ROLLING_POLICY_PROPERTY} and
* the max number of files defined in property {@link #MAX_FILES_PROPERTY}</li>
* <li>the logs will follow the specified log pattern</li>
* </ul>
* </p>
*
* @see #buildLogPattern(RootLoggerConfig)
*/
public FileAppender<ILoggingEvent> configureGlobalFileLog(Props props, RootLoggerConfig config, String logPattern) {
LoggerContext ctx = getRootContext();
Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME);
FileAppender<ILoggingEvent> fileAppender = newFileAppender(ctx, props, config, logPattern);
rootLogger.addAppender(fileAppender);
return fileAppender;
}
use of ch.qos.logback.classic.Logger in project sonarqube by SonarSource.
the class SearchLoggingTest method do_not_log_to_console.
@Test
public void do_not_log_to_console() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(ROOT_LOGGER_NAME);
Appender appender = root.getAppender("CONSOLE");
assertThat(appender).isNull();
}
use of ch.qos.logback.classic.Logger 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);
}
}
use of ch.qos.logback.classic.Logger in project Alpha by alpha-asp.
the class ChoiceManagerTests 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);
}
Aggregations