Skip to content

Introduce Spring Boot starter #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
696f32b
Next version (1.1.0-SNAPSHOT)
dmitrysulman May 17, 2025
44d2c67
Spring Boot starter baseline
dmitrysulman May 18, 2025
e8aa2be
Rename module
dmitrysulman May 22, 2025
ec9e3d7
Continue worker on starter
dmitrysulman May 24, 2025
2296bda
Continue worker on starter
dmitrysulman May 24, 2025
abae6fe
Fix dokka Module description
dmitrysulman May 24, 2025
1ff6550
Improve default configuration handling
dmitrysulman May 24, 2025
c64d32d
Start Joran Configurator
dmitrysulman May 29, 2025
10a2a08
Move conventions to libs.versions.toml
dmitrysulman May 30, 2025
d42ccfd
Continue Joran configuration
dmitrysulman May 30, 2025
f76cc78
Add Spring Boot documentation links
dmitrysulman May 30, 2025
9b5627e
Add documentation to Joran classes
dmitrysulman May 30, 2025
7a3027e
Expose ReactorNettyAccessLogFactory as a bean
dmitrysulman May 30, 2025
8a13f9f
Add tests
dmitrysulman May 31, 2025
a2c5a83
Add springProfile SanityChecker
dmitrysulman Jun 1, 2025
d10cbe3
Add test for the null model
dmitrysulman Jun 2, 2025
101bfee
Add tests for Joran
dmitrysulman Jun 4, 2025
d09ab41
Add tests for Joran
dmitrysulman Jun 4, 2025
ac1d60e
Add additional autoconfiguration tests
dmitrysulman Jun 10, 2025
2ef3673
Improve integration tests
dmitrysulman Jun 11, 2025
04a53d6
Add tests
dmitrysulman Jun 12, 2025
3b7f82c
Add more tests
dmitrysulman Jun 12, 2025
968fe9f
Start fixing README.md
dmitrysulman Jun 12, 2025
e646d7b
Continue fixing README.md
dmitrysulman Jun 12, 2025
c864ae1
Continue fixing README.md
dmitrysulman Jun 13, 2025
82b88b0
Update Dokka configuration
dmitrysulman Jun 13, 2025
9bc025d
Continue fixing README.md
dmitrysulman Jun 13, 2025
09f0639
Continue fixing README.md
dmitrysulman Jun 14, 2025
2fdf7c8
Continue fixing README.md
dmitrysulman Jun 14, 2025
066b546
Continue fixing README.md
dmitrysulman Jun 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 114 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@
[![CodeQL](https://github.com/dmitrysulman/logback-access-reactor-netty/actions/workflows/codeql.yml/badge.svg)](https://github.com/dmitrysulman/logback-access-reactor-netty/actions/workflows/codeql.yml)
[![codecov](https://codecov.io/gh/dmitrysulman/logback-access-reactor-netty/graph/badge.svg?token=LOEJQ7K8Z7)](https://codecov.io/gh/dmitrysulman/logback-access-reactor-netty)

A Java/Kotlin library that integrates Logback Access with Reactor Netty HTTP server, providing comprehensive access logging capabilities.
A Java/Kotlin library and Spring Boot Starter that integrates Logback Access with Reactor Netty HTTP server, providing comprehensive access logging capabilities for reactive web applications.

## Contents:

- [Overview](#overview)
- [Features](#features)
- [Usage](#usage)
- [Using as a Spring Boot Starter](#using-as-a-spring-boot-starter)
- [Adding Spring Boot Starter to your project](#adding-spring-boot-starter-to-your-project)
- [Configuration](#configuration)
- [Application properties](#application-properties)
- [Profile-specific configuration](#profile-specific-configuration)
- [Dependencies](#dependencies)
- [Using as a standalone library](#using-as-a-standalone-library)
- [Adding dependency to your project](#adding-dependency-to-your-project)
- [Basic setup](#basic-setup)
- [Customize Logback Access configuration](#customize-logback-access-configuration)
- [Dependencies](#dependencies-1)
- [API documentation](#api-documentation)
- [See also](#see-also)

## Overview

Expand All @@ -17,43 +36,108 @@ A Java/Kotlin library that integrates Logback Access with Reactor Netty HTTP ser

## Features

- Spring Boot Starter with auto-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

## Dependencies
## Usage

The Logback Access integration with Reactor Netty can be used in two ways:

1. As a Spring Boot Starter for reactive Spring Boot applications based on `spring-boot-starter-webflux`.
2. As a standalone library for applications using Reactor Netty HTTP Server directly.

## Using as a Spring Boot Starter

### Adding Spring Boot Starter to your project

The Spring Boot Starter is published on [Maven Central](https://central.sonatype.com/artifact/io.github.dmitrysulman/logback-access-reactor-netty-spring-boot-starter). To add the dependency, use the following snippet according to your build system:

#### Gradle

```
implementation("io.github.dmitrysulman:logback-access-reactor-netty-spring-boot-starter:1.1.0")
```

#### Maven
```
<dependency>
<groupId>io.github.dmitrysulman</groupId>
<artifactId>logback-access-reactor-netty-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
```

### Configuration

Default Spring Boot auto-configuration uses the `logback-access.xml` file from the current directory or the classpath, with a fallback to the [Common Log Format](https://en.wikipedia.org/wiki/Common_Log_Format).

#### Application properties

Several application properties can be specified inside `application.properties` file or `application.yaml` file, or as command line arguments:

| Name | Description | Default Value |
|:---------------------------------------|:--------------------------------------------------------|:---------------------|
| `logback.access.reactor.netty.enabled` | Enable Logback Access Reactor Netty auto-configuration. | `true` |
| `logback.access.reactor.netty.config` | Config file name. | `logback-access.xml` |
| `logback.access.reactor.netty.debug` | Enable debug mode. | `false` |

#### Profile-specific configuration

The `<springProfile>` tag allows you to conditionally include or exclude parts of the configuration based on the active Spring profiles. You can use it anywhere within the `<configuration>` element. Specify the applicable profile using the `name` attribute, which can be either a single profile name (e.g., `staging`) or a profile expression. For more details, see the [Spring Boot Logback Extensions Profile-specific Configuration reference guide](https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.logback-extensions.profile-specific), which describes the same usage. There are several examples:

```xml
<springProfile name="staging">
<!-- configuration to be enabled when the "staging" profile is active -->
</springProfile>

<springProfile name="dev | staging">
<!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
</springProfile>

<springProfile name="!production">
<!-- configuration to be enabled when the "production" profile is not active -->
</springProfile>
```

### Dependencies

- Java 17+
- Kotlin Standard Library 2.1.21
- Reactor Netty HTTP Server 1.2.6+ (should be explicitly provided)
- Spring Boot Starter WebFlux 3.4.6+ (should be explicitly provided)
- Logback-access 2.0.6
- SLF4J 2.0.17

## Usage
## Using as a standalone library

### Adding dependency
### Adding dependency to your project

The library is published on [Maven Central](https://central.sonatype.com/artifact/io.github.dmitrysulman/logback-access-reactor-netty). To add the dependency, use the following snippet according to your build system:

##### Gradle

```
implementation("io.github.dmitrysulman:logback-access-reactor-netty:1.1.0")
```

#### Maven

```
<dependency>
<groupId>io.github.dmitrysulman</groupId>
<artifactId>logback-access-reactor-netty</artifactId>
<version>1.0.7</version>
<version>1.1.0</version>
</dependency>
```

#### Gradle

```
implementation("io.github.dmitrysulman:logback-access-reactor-netty:1.0.7")
```

### Basic Setup

To enable Logback Access integration with Reactor Netty, create a new instance of `ReactorNettyAccessLogFactory` and pass it to the `HttpServer.accessLog()` method.

#### Java

```java
Expand All @@ -67,6 +151,8 @@ HttpServer.create()

#### Kotlin

For Kotlin, a convenient [enableLogbackAccess()](https://dmitrysulman.github.io/logback-access-reactor-netty/logback-access-reactor-netty/io.github.dmitrysulman.logback.access.reactor.netty/enable-logback-access.html) extension function is provided to pass the factory instance.

```kotlin
val factory = ReactorNettyAccessLogFactory()
HttpServer.create()
Expand All @@ -76,13 +162,14 @@ HttpServer.create()
.block()
```

### Configuration
### Customize Logback Access configuration

The library can be configured in several ways:

1. **Default configuration** uses the `logback-access.xml` file from the classpath or the current directory, with a fallback to the [Common Log Format](https://en.wikipedia.org/wiki/Common_Log_Format).
1. **Default configuration** uses the `logback-access.xml` file from the current directory or the classpath, with a fallback to the [Common Log Format](https://en.wikipedia.org/wiki/Common_Log_Format).
2. **System property.** Set `-Dlogback.access.reactor.netty.config` property to specify configuration file location.
3. **Programmatic configuration.** Provide configuration file filename or URL of the classpath resource directly:

```java
// Using specific configuration file by the filename
var factory = new ReactorNettyAccessLogFactory("/path/to/logback-access.xml");
Expand All @@ -93,44 +180,25 @@ var factory = new ReactorNettyAccessLogFactory(
);
```

### Spring Boot configuration

#### Java
### Dependencies

```java
@Configuration
public class NettyAccessLogConfiguration {
@Bean
public NettyServerCustomizer accessLogNettyServerCustomizer() {
return (server) ->
server.accessLog(true, new ReactorNettyAccessLogFactory("path/to/your/logback-access.xml"));
}
}
```

#### Kotlin
```kotlin
@Configuration
class NettyAccessLogConfiguration {
@Bean
fun accessLogNettyServerCustomizer() =
NettyServerCustomizer { server ->
server.enableLogbackAccess(ReactorNettyAccessLogFactory("path/to/your/logback-access.xml"))
}
}
```
See [enableLogbackAccess()](https://dmitrysulman.github.io/logback-access-reactor-netty/logback-access-reactor-netty/io.github.dmitrysulman.logback.access.reactor.netty/enable-logback-access.html) extension function documentation.
- Java 17+
- Kotlin Standard Library 2.1.21
- Reactor Netty HTTP Server 1.2.6+ (should be explicitly provided)
- Logback-access 2.0.6
- SLF4J 2.0.17

## Documentation
## API documentation

- [Java API (Javadoc)](https://javadoc.io/doc/io.github.dmitrysulman/logback-access-reactor-netty/latest/index.html)
- [Java API (Javadoc) - Spring Boot Starter](https://javadoc.io/doc/io.github.dmitrysulman/logback-access-reactor-netty-spring-boot-starter/latest/index.html)
- [Java API (Javadoc) - Standalone library](https://javadoc.io/doc/io.github.dmitrysulman/logback-access-reactor-netty/latest/index.html)
- [Kotlin API (KDoc)](https://dmitrysulman.github.io/logback-access-reactor-netty/)

## Author

[Dmitry Sulman](https://www.linkedin.com/in/dmitrysulman/)

## See Also

- [Reactor Netty HTTP Server Documentation](https://projectreactor.io/docs/netty/release/reference/http-server.html)
- [Logback Access Documentation](https://logback.qos.ch/access.html)

## Author

[Dmitry Sulman](https://www.linkedin.com/in/dmitrysulman/)
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group = "io.github.dmitrysulman"

dependencies {
dokka(project("logback-access-reactor-netty"))
dokka(project("logback-access-reactor-netty-spring-boot-starter"))
}

tasks.jreleaserFullRelease {
Expand Down
20 changes: 14 additions & 6 deletions buildSrc/src/main/kotlin/conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,24 @@ dokka {
}
externalDocumentationLinks {
register("reactor-netty-docs") {
url("https://projectreactor.io/docs/netty/${libs.versions.reactorNetty.get()}/api/")
packageListUrl("https://projectreactor.io/docs/netty/${libs.versions.reactorNetty.get()}/api/package-list")
url("https://projectreactor.io/docs/netty/release/api/")
packageListUrl("https://projectreactor.io/docs/netty/release/api/package-list")
}
register("logback-access-docs") {
url("https://javadoc.io/doc/ch.qos.logback.access/logback-access-common/${libs.versions.logbackAccess.get()}/")
packageListUrl("https://javadoc.io/doc/ch.qos.logback.access/logback-access-common/${libs.versions.logbackAccess.get()}/element-list")
url("https://javadoc.io/doc/ch.qos.logback.access/logback-access-common/latest/")
packageListUrl("https://javadoc.io/doc/ch.qos.logback.access/logback-access-common/latest/element-list")
}
register("logback-core-docs") {
url("https://javadoc.io/doc/ch.qos.logback/logback-core/${libs.versions.logbackClassic.get()}/")
packageListUrl("https://javadoc.io/doc/ch.qos.logback/logback-core/${libs.versions.logbackClassic.get()}/element-list")
url("https://javadoc.io/doc/ch.qos.logback/logback-core/latest/")
packageListUrl("https://javadoc.io/doc/ch.qos.logback/logback-core/latest/element-list")
}
register("spring-framework-docs") {
url("https://docs.spring.io/spring-framework/docs/current/javadoc-api/")
packageListUrl("https://docs.spring.io/spring-framework/docs/current/javadoc-api/element-list")
}
register("spring-boot-docs") {
url("https://docs.spring.io/spring-boot/api/java/")
packageListUrl("https://docs.spring.io/spring-boot/api/java/element-list")
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version=1.0.8-SNAPSHOT
version=1.1.0-SNAPSHOT
org.gradle.caching=true
org.gradle.configuration-cache=false
org.gradle.jvmargs=-Xmx2g
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
kapt.use.k2=true
13 changes: 12 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[versions]
assertj = "3.27.3"
dokka = "2.0.0"
jackson = "2.19.0"
java = "17"
Expand All @@ -14,8 +15,10 @@ logbackClassic = "1.5.18"
mockk = "1.14.2"
reactorNetty = "1.2.7"
slf4j = "2.0.17"
springBoot = "3.4.6"

[libraries]
assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" }
dokka-plugin = { group = "org.jetbrains.dokka", name = "org.jetbrains.dokka.gradle.plugin", version.ref = "dokka" }
dokka-javadoc-plugin = { group = "org.jetbrains.dokka-javadoc", name = "org.jetbrains.dokka-javadoc.gradle.plugin", version.ref = "dokka" }
jackson-bom = { group = "com.fasterxml.jackson", name = "jackson-bom", version.ref = "jackson" }
Expand All @@ -31,7 +34,15 @@ logback-classic = { group = "ch.qos.logback", name = "logback-classic", version.
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
reactorNetty-http = { group = "io.projectreactor.netty", name = "reactor-netty-http", version.ref = "reactorNetty" }
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
spring-boot-autoconfigureProcessor = { group = "org.springframework.boot", name = "spring-boot-autoconfigure-processor", version.ref = "springBoot" }
spring-boot-configurationProcessor = { group = "org.springframework.boot", name = "spring-boot-configuration-processor", version.ref = "springBoot" }
spring-boot-starter = { group = "org.springframework.boot", name = "spring-boot-starter", version.ref = "springBoot" }
spring-boot-starter-reactorNetty = { group = "org.springframework.boot", name = "spring-boot-starter-reactor-netty", version.ref = "springBoot" }
spring-boot-starter-test = { group = "org.springframework.boot", name = "spring-boot-starter-test", version.ref = "springBoot" }
spring-boot-starter-webflux = { group = "org.springframework.boot", name = "spring-boot-starter-webflux", version.ref = "springBoot" }

[plugins]
dokka = { id = "org.jetbrains.dokka" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
conventions = { id = "conventions" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
kotlin-springPlugin = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
25 changes: 25 additions & 0 deletions logback-access-reactor-netty-spring-boot-starter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
alias(libs.plugins.conventions)
alias(libs.plugins.kotlin.springPlugin)
kotlin("kapt")
}

description = "Spring Boot Starter for Logback Access integration with Reactor Netty"

dependencies {
api(project(":logback-access-reactor-netty"))

implementation(libs.spring.boot.starter)
implementation(libs.slf4j.api)

provided(libs.spring.boot.starter.reactorNetty)

kapt(libs.spring.boot.autoconfigureProcessor)
kapt(libs.spring.boot.configurationProcessor)

testImplementation(libs.assertj.core)
testImplementation(libs.kotest.assertions.core.jvm)
testImplementation(libs.mockk)
testImplementation(libs.spring.boot.starter.test)
testImplementation(libs.spring.boot.starter.webflux)
}
Loading
Loading