https://github.com/dev-jonghoonpark/spring-http-logger
This library assists logging for Spring HTTP clients (RestClient, WebClient).
https://github.com/dev-jonghoonpark/spring-http-logger
Last synced: 7 months ago
JSON representation
This library assists logging for Spring HTTP clients (RestClient, WebClient).
- Host: GitHub
- URL: https://github.com/dev-jonghoonpark/spring-http-logger
- Owner: dev-jonghoonpark
- License: apache-2.0
- Created: 2025-06-22T04:52:17.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-22T15:04:41.000Z (about 1 year ago)
- Last Synced: 2025-10-12T09:17:41.843Z (10 months ago)
- Language: Java
- Homepage:
- Size: 157 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-http-logger
This library assists logging for Spring HTTP clients (RestClient, WebClient).
## Download
### Gradle
```groovy
implementation 'com.jonghoonpark:spring-http-logger:1.0.0'
```
### Maven
```xml
com.jonghoonpark
spring-http-logger
1.0.0
```
## How to use
### RestClient
Use `ClientLoggerRequestInterceptor`.
```java
RestClient restClient = RestClient.builder()
.requestInterceptor(new ClientLoggerRequestInterceptor())
.build();
```
### WebClient (reactive)
Use `LoggingClientHttpConnector` and `RequestLoggingExchangeFilterFunction`.
```java
WebClient webClient = WebClient.builder()
.clientConnector(new LoggingClientHttpConnector())
.filter(RequestLoggingExchangeFilterFunction.logRequest())
.build();
```
### Examples in Action


### Logging config
`request/response bodies` are configured to be logged at the `INFO` level.
If you also want to see `request/response headers`, set the logging level to `DEBUG`.
```
logging.level.com.jonghoonpark=debug
```
## reference
- Portions of the code are adapted from:
- rest client: https://github.com/spring-projects/spring-ai/issues/883#issuecomment-2739772323
- web client (reactive): https://stackoverflow.com/a/73154616/29672082