use of ch.qos.logback.core.encoder.Encoder in project qpid-broker-j by apache.
the class AppenderUtilsTest method testCreateRollingFileAppenderNonDailyRolling.
@Test
public void testCreateRollingFileAppenderNonDailyRolling() {
when(_settings.isRollDaily()).thenReturn(Boolean.FALSE);
when(_settings.isCompressOldFiles()).thenReturn(Boolean.FALSE);
RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
AppenderUtils.configureRollingFileAppender(_settings, new LoggerContext(), appender);
assertEquals("Unexpected appender file name", _testLogFileName, appender.getFile());
RollingPolicy rollingPolicy = appender.getRollingPolicy();
final boolean condition2 = rollingPolicy instanceof RollingPolicyDecorator;
assertTrue("Unexpected rolling policy", condition2);
rollingPolicy = ((RollingPolicyDecorator) rollingPolicy).getDecorated();
final boolean condition1 = rollingPolicy instanceof AppenderUtils.SimpleRollingPolicy;
assertTrue("Unexpected decorated rolling policy", condition1);
assertEquals("Unexpected max history", (long) MAX_HISTORY, (long) ((AppenderUtils.SimpleRollingPolicy) rollingPolicy).getMaxIndex());
assertEquals("Unexpected file name pattern", _testLogFileName + ".%i", ((AppenderUtils.SimpleRollingPolicy) rollingPolicy).getFileNamePattern());
assertEquals("Unexpected compression mode", CompressionMode.NONE, rollingPolicy.getCompressionMode());
TriggeringPolicy triggeringPolicy = appender.getTriggeringPolicy();
assertEquals("Unexpected triggering policy", String.valueOf(MAX_FILE_SIZE) + " MB", ((AppenderUtils.SizeTriggeringPolicy) triggeringPolicy).getMaxFileSize().toString());
Encoder encoder = appender.getEncoder();
final boolean condition = encoder instanceof PatternLayoutEncoder;
assertTrue("Unexpected encoder", condition);
assertEquals("Unexpected layout pattern", LAYOUT, ((PatternLayoutEncoder) encoder).getPattern());
}
use of ch.qos.logback.core.encoder.Encoder in project kie-wb-common by kiegroup.
the class LogbackConfigTest method configureLoggingProgrammatically.
@Test
public void configureLoggingProgrammatically() {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
LogbackConfig config = new LogbackConfig();
config.configure(loggerContext);
root.info("test appender");
Appender<ILoggingEvent> kieSift = root.getAppender("KieSift");
assertThat(kieSift).isNotNull();
KieSiftingAppender kieSiftAppender = (KieSiftingAppender) kieSift;
assertThat(kieSiftAppender).isNotNull();
assertThat(kieSiftAppender.getDiscriminator()).isNotNull();
assertThat(MavenConfig.COMPILATION_ID).isEqualTo(kieSiftAppender.getDiscriminatorKey());
Appender<ILoggingEvent> consoleAppenderGeneric = root.getAppender("consoleAppender");
ConsoleAppender consoleAppender = (ConsoleAppender) consoleAppenderGeneric;
assertThat(consoleAppender).isNotNull();
Encoder enc = consoleAppender.getEncoder();
PatternLayoutEncoder encoder = (PatternLayoutEncoder) enc;
assertThat(encoder.getPattern()).isEqualTo("%d [%thread] %level %logger{35} - %msg%n");
}
Aggregations