use of ch.qos.logback.core.Appender in project qpid-broker-j by apache.
the class JDBCVirtualHostLoggerImplTest method createAppenderOnOpen.
@Test
public void createAppenderOnOpen() {
_logger.open();
final Appender appender = ROOT_LOGGER.getAppender(getTestName());
assertTrue(appender instanceof DBAppender);
}
use of ch.qos.logback.core.Appender in project qpid-broker-j by apache.
the class JDBCVirtualHostLoggerImplTest method detachAppenderInstanceOnDelete.
@Test
public void detachAppenderInstanceOnDelete() {
_logger.create();
_logger.delete();
final Appender appender = ROOT_LOGGER.getAppender(getTestName());
assertNull(appender);
}
use of ch.qos.logback.core.Appender in project qpid-broker-j by apache.
the class BrokerLoggerTest method setUp.
@Before
public void setUp() throws Exception {
_taskExecutor = new TaskExecutorImpl();
_taskExecutor.start();
_loggerAppender = new ListAppender<>();
_loggerAppender.setName(APPENDER_NAME);
Model model = BrokerModel.getInstance();
_broker = mock(Broker.class);
when(_broker.getCategoryClass()).thenReturn(Broker.class);
when(_broker.getTypeClass()).thenReturn(Broker.class);
when(_broker.getModel()).thenReturn(model);
when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
doReturn(Broker.class).when(_broker).getCategoryClass();
Map<String, Object> attributes = new HashMap<>();
attributes.put("name", APPENDER_NAME);
_brokerLogger = new AbstractBrokerLogger(attributes, _broker) {
@Override
public Appender<ILoggingEvent> createAppenderInstance(Context context) {
return _loggerAppender;
}
};
_brokerLogger.open();
}
use of ch.qos.logback.core.Appender in project reactor-netty by reactor.
the class HttpProtocolsTests method testAccessLog.
@ParameterizedCompatibleCombinationsTest
@SuppressWarnings("unchecked")
void testAccessLog(HttpServer server, HttpClient client) throws Exception {
disposableServer = server.handle((req, resp) -> {
resp.withConnection(conn -> {
ChannelHandler handler = conn.channel().pipeline().get(NettyPipeline.AccessLogHandler);
resp.header(NettyPipeline.AccessLogHandler, handler != null ? "FOUND" : "NOT FOUND");
});
return resp.send();
}).accessLog(true).bindNow();
Appender<ILoggingEvent> mockedAppender = (Appender<ILoggingEvent>) Mockito.mock(Appender.class);
ArgumentCaptor<LoggingEvent> loggingEventArgumentCaptor = ArgumentCaptor.forClass(LoggingEvent.class);
Mockito.when(mockedAppender.getName()).thenReturn("MOCK");
Logger accessLogger = (Logger) LoggerFactory.getLogger("reactor.netty.http.server.AccessLog");
AtomicReference<String> protocol = new AtomicReference<>();
try {
accessLogger.addAppender(mockedAppender);
client.port(disposableServer.port()).get().uri("/").responseSingle((res, bytes) -> {
protocol.set(res.responseHeaders().get("x-http2-stream-id") != null ? "2.0" : "1.1");
return Mono.just(res.responseHeaders().get(NettyPipeline.AccessLogHandler));
}).as(StepVerifier::create).expectNext("FOUND").expectComplete().verify(Duration.ofSeconds(5));
} finally {
Thread.sleep(20);
Mockito.verify(mockedAppender, Mockito.times(1)).doAppend(loggingEventArgumentCaptor.capture());
assertThat(loggingEventArgumentCaptor.getAllValues()).hasSize(1);
LoggingEvent relevantLog = loggingEventArgumentCaptor.getAllValues().get(0);
assertThat(relevantLog.getFormattedMessage()).contains("GET / HTTP/" + protocol.get() + "\" 200");
accessLogger.detachAppender(mockedAppender);
}
}
use of ch.qos.logback.core.Appender in project sonarqube by SonarSource.
the class CeProcessLoggingTest 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");
}
Aggregations