use of ch.qos.logback.access.spi.IAccessEvent in project dropwizard by dropwizard.
the class LogbackAccessRequestLogFactory method build.
@Override
public RequestLog build(String name) {
final Logger logger = (Logger) LoggerFactory.getLogger("http.request");
logger.setAdditive(false);
final LoggerContext context = logger.getLoggerContext();
final LogbackAccessRequestLog requestLog = new LogbackAccessRequestLog();
final LevelFilterFactory<IAccessEvent> levelFilterFactory = new NullLevelFilterFactory<>();
final AsyncAppenderFactory<IAccessEvent> asyncAppenderFactory = new AsyncAccessEventAppenderFactory();
final LayoutFactory<IAccessEvent> layoutFactory = new LogbackAccessRequestLayoutFactory();
for (AppenderFactory<IAccessEvent> output : appenders) {
requestLog.addAppender(output.build(context, name, layoutFactory, levelFilterFactory, asyncAppenderFactory));
}
return requestLog;
}
use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.
the class AbstractLogbackAccessEventsTest method logbackAccessEventWithoutContentLengthResponseHeader.
/**
* Tests a Logback-access event without a response header of content length.
*/
@Test
public void logbackAccessEventWithoutContentLengthResponseHeader() {
ResponseEntity<String> response = rest.getForEntity("/test/json", String.class);
IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
LogbackAccessEventQueuingListener.appendedEventQueue.pop();
assertThat(response).hasStatusCode(HttpStatus.OK).doesNotHaveContentLengthHeader().hasBody("{\"TEST-KEY\":\"TEST-VALUE\"}");
assertThat(event).hasContentLength("{\"TEST-KEY\":\"TEST-VALUE\"}".getBytes(StandardCharsets.UTF_8).length);
}
use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.
the class AbstractLogbackAccessEventsTest method logbackAccessEventAsynchronously.
/**
* Tests a Logback-access event asynchronously.
*/
@Test
public void logbackAccessEventAsynchronously() {
ResponseEntity<String> response = rest.getForEntity("/test/text-asynchronously", String.class);
IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
LogbackAccessEventQueuingListener.appendedEventQueue.pop();
assertThat(response).hasStatusCode(HttpStatus.OK);
assertThat(event).hasThreadName();
}
use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.
the class AbstractLogbackAccessEventsTest method logbackAccessEventWithQueryString.
/**
* Tests a Logback-access event with a query string.
*/
@Test
public void logbackAccessEventWithQueryString() {
ResponseEntity<String> response = rest.getForEntity("/test/text?query", String.class);
IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
LogbackAccessEventQueuingListener.appendedEventQueue.pop();
assertThat(response).hasStatusCode(HttpStatus.OK);
assertThat(event).hasRequestUri("/test/text").hasQueryString("?query").hasRequestUrl(HttpMethod.GET, "/test/text?query", "HTTP/1.1");
}
use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.
the class AbstractLogbackAccessEventsTest method logbackAccessEventToGetEmptyText.
/**
* Tests a Logback-access event to get empty text.
*/
@Test
public void logbackAccessEventToGetEmptyText() {
ResponseEntity<String> response = rest.getForEntity("/test/empty-text", String.class);
IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
LogbackAccessEventQueuingListener.appendedEventQueue.pop();
assertThat(response).hasStatusCode(HttpStatus.OK).hasContentLengthHeader(0);
assertThat(event).hasContentLength(0);
}
Aggregations