A Java/Kotlin library that integrates Logback Access with Reactor Netty HTTP server, providing comprehensive access logging capabilities.
Reactor Netty HTTP Server is a non-blocking, asynchronous server built on the Netty networking framework and used as the default runtime for handling HTTP requests in Spring WebFlux. It enables reactive, event-driven processing of web requests, making it well-suited for scalable and high-throughput applications. In Spring Boot, it's automatically configured when building reactive applications with the spring-boot-starter-webflux
dependency.
Logback Access is a module of the Logback logging framework that provides HTTP access logging capabilities, similar to those in servlet containers like Tomcat or Jetty. It allows logging of incoming HTTP requests and responses using customizable patterns and supports easy configuration through an XML file.
Logback Access for Reactor Netty library serves as a bridge between the Reactor Netty HTTP logging mechanism and the Logback Access library. It enables detailed HTTP access logging with configurable formats, filters, and appenders through Logback Access configuration.
- XML-based configuration support
- Comprehensive HTTP request/response logging
- Lazy-loaded access event properties for optimal performance
- Support for headers, cookies, and request parameters logging
- Configurable through system properties or external configuration files
- Debug mode for troubleshooting
- Java 17+
- Kotlin Standard Library 2.1.21
- Reactor Netty HTTP Server 1.2.6
- Logback-access 2.0.6
- SLF4J 2.0.17
<dependency>
<groupId>io.github.dmitrysulman</groupId>
<artifactId>logback-access-reactor-netty</artifactId>
<version>1.0.4</version>
</dependency>
implementation("io.github.dmitrysulman:logback-access-reactor-netty:1.0.4")
ReactorNettyAccessLogFactory factory = new ReactorNettyAccessLogFactory();
HttpServer.create()
.accessLog(true, factory)
.bindNow()
.onDispose()
.block();
val factory = ReactorNettyAccessLogFactory()
HttpServer.create()
.enableLogbackAccess(factory)
.bindNow()
.onDispose()
.block()
The library can be configured in several ways:
- Default configuration uses
logback-access.xml
file on the classpath. - System property. Set
-Dlogback.access.reactor.netty.config
property to specify configuration file location. - Programmatic configuration. Provide configuration file filename or URL of the resource directly:
// Using specific configuration file by the filename
var factory = new ReactorNettyAccessLogFactory("/path/to/logback-access.xml");
// Using specific configuration file as a classpath resource
var factory = new ReactorNettyAccessLogFactory(
this.getClass().getClassLoader().getResource("custom-logback-access.xml")
);
@Configuration
public class NettyAccessLogConfiguration {
@Bean
public NettyServerCustomizer accessLogNettyServerCustomizer() {
return (server) ->
server.accessLog(true, new ReactorNettyAccessLogFactory("path/to/your/logback-access.xml"));
}
}
@Configuration
class NettyAccessLogConfiguration {
@Bean
fun accessLogNettyServerCustomizer() =
NettyServerCustomizer { server ->
server.enableLogbackAccess(ReactorNettyAccessLogFactory("path/to/your/logback-access.xml"))
}
}
See enableLogbackAccess() extension function documentation.