use of org.sonar.process.logging.PatternLayoutEncoder in project sonarqube by SonarSource.
the class AppLoggingTest method verifyFormattedLogEncoder.
private void verifyFormattedLogEncoder(Encoder<ILoggingEvent> encoder, String logPattern) {
assertThat(encoder).isInstanceOf(PatternLayoutEncoder.class);
PatternLayoutEncoder patternEncoder = (PatternLayoutEncoder) encoder;
assertThat(patternEncoder.getPattern()).isEqualTo(logPattern);
}
use of org.sonar.process.logging.PatternLayoutEncoder in project sonarqube by SonarSource.
the class WebServerProcessLoggingTest 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");
}
use of org.sonar.process.logging.PatternLayoutEncoder in project sonarqube by SonarSource.
the class WebServerProcessLoggingTest method log_to_web_file.
@Test
public void log_to_web_file() {
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(Logger.ROOT_LOGGER_NAME);
Appender<ILoggingEvent> appender = root.getAppender("file_web");
assertThat(appender).isInstanceOf(FileAppender.class);
FileAppender fileAppender = (FileAppender) appender;
assertThat(fileAppender.getFile()).isEqualTo(new File(logDir, "web.log").getAbsolutePath());
assertThat(fileAppender.getEncoder()).isInstanceOf(PatternLayoutEncoder.class);
PatternLayoutEncoder encoder = (PatternLayoutEncoder) fileAppender.getEncoder();
assertThat(encoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level web[%X{HTTP_REQUEST_ID}][%logger{20}] %msg%n");
}
use of org.sonar.process.logging.PatternLayoutEncoder in project sonarqube by SonarSource.
the class WebServerProcessLoggingTest method log_for_cluster_changes_layout_in_file_and_console.
@Test
public void log_for_cluster_changes_layout_in_file_and_console() {
props.set("sonar.cluster.enabled", "true");
props.set("sonar.cluster.node.name", "my-node");
LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(Logger.ROOT_LOGGER_NAME);
FileAppender fileAppender = (FileAppender) root.getAppender("file_web");
PatternLayoutEncoder encoder = (PatternLayoutEncoder) fileAppender.getEncoder();
assertThat(encoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level my-node web[%X{HTTP_REQUEST_ID}][%logger{20}] %msg%n");
Logger startup = ctx.getLogger("startup");
ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) startup.getAppender("CONSOLE");
PatternLayoutEncoder patternEncoder = (PatternLayoutEncoder) consoleAppender.getEncoder();
assertThat(patternEncoder.getPattern()).isEqualTo("%d{yyyy.MM.dd HH:mm:ss} %-5level my-node app[][%logger{20}] %msg%n");
}
use of org.sonar.process.logging.PatternLayoutEncoder in project sonarqube by SonarSource.
the class AppLogging method createGobblerEncoder.
/**
* Simply displays the message received as input.
*/
private static Encoder<ILoggingEvent> createGobblerEncoder(LoggerContext context) {
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern("%msg%n");
encoder.start();
return encoder;
}
Aggregations