Closed evkaky closed 1 year ago
Hi @evkaky think it will be included in version 3.0.x. See https://github.com/zalando/logbook/issues/1344
Hi @willlie1
I just tried to bounce version to org.zalando:logbook-spring-boot-starter:3.0.0-RC.0
Nothing changed. Is it expected the release candidate version 3.0.0-RC.0
doesn't work either?
Hello @evkaky
In order to make logbook work with webflux, you have just to include this dependency logbook-spring-webflux
.
And inject LogbookExchangeFilterFunction
to your client.
Here is the snippet of SpringApplication.java
:
@SpringBootApplication
public class LogbookWebClientApplication {
public static void main(String[] args) {
SpringApplication.run(LogbookWebClientApplication.class, args);
}
@Bean
Logbook logbook() {
return Logbook.create();
}
@Bean
public ApplicationRunner onStart(WebClient.Builder webClientBuilder, Logbook logbook) {
return args -> {
var webClient = webClientBuilder
.baseUrl("https://jsonplaceholder.typicode.com")
.filter(new LogbookExchangeFilterFunction(logbook))
.build();
Todo resp = webClient
.get()
.uri("todos/{id}", 1)
.retrieve()
.bodyToMono(Todo.class)
.block();
};
}
}
At startup you should have logs for Outgoing and Incoming Response. Hope that helps you.
For spring-webflux application you'd need to use logbook-spring-boot-webflux-autoconfigure
as a dependency.
But it looks like the org.springframework.boot.autoconfigure.AutoConfiguration.imports file is missing in logbook-spring-boot-webflux-autoconfigure
module. Without it, the LogbookWebFluxAutoConfiguration
class is not loaded by default. Until it's added, you'd need to add the filter directly as @Larkhis suggested or Import LogbookWebFluxAutoConfiguration
to your spring boot app.
I'll open a PR for it.
The autoconfiguration part should be fixed in the next release. I'll resolve the issue. Feel free to reopen if you still need support here.
Springboot 3.3.1 with logbook-spring-boot-start version 3.9.0
Thx
For spring-webflux application you'd need to use
logbook-spring-boot-webflux-autoconfigure
as a dependency.But it looks like the org.springframework.boot.autoconfigure.AutoConfiguration.imports file is missing in
logbook-spring-boot-webflux-autoconfigure
module. Without it, theLogbookWebFluxAutoConfiguration
class is not loaded by default. Until it's added, you'd need to add the filter directly as @Larkhis suggested or ImportLogbookWebFluxAutoConfiguration
to your spring boot app. I'll open a PR for it.
In my Spring Boot WebFlux project, I am unable to generate any logs using Logbook.
Here is the relevant section from my pom.xml:
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-spring-boot-autoconfigure</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-spring-boot-webflux-autoconfigure</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-netty</artifactId>
<version>3.9.0</version>
</dependency>
The configuration in application.yml is as follows:
logbook:
format: json
strategy: default
filter:
enabled: true
exclude:
- /swagger
- /api-docs
- /actuator
obfuscate:
headers:
- Authorization
- Cookie
parameters:
- password
body:
patterns:
- '"password": ".*"'
write:
level: DEBUG
category: logbook.log
max-body-size: 1000
exclude:
content-types:
- application/octet-stream
...
logging:
level:
org.zalando: DEBUG
You've missed to post your logging (framework) configuration.
You've missed to post your logging (framework) configuration.
Updated
You configure Logbook to use the category (aka logger name) "category: logbook.log" but then you configure your logging framework to change the log level of "org.zalando". Those need to be aligned. You can just delete the line with "category" and then it should already work.
(This has nothing to do with Logbook, technically. Just logging framework configuration.)
I removed the category entirely, but I'm still not seeing any output. I also set write.level = INFO for both Logbook and the root logger, but nothing.
The full category name is org.zalando.logbook.Logbook
(see https://github.com/zalando/logbook?tab=readme-ov-file#writing). Maybe your logging framework needs to configure the full name and not just the prefix. No idea.
Could you provide some advice on how to debug this issue? Specifically, which important classes should I focus on, and where would be the best places to set breakpoints?
DefaultStrategy and DefaultHttpLogWriter are good candidates. Both should be triggering in the happy case. If they do, then your problem is outside of Logbook.
On Wed, Aug 28, 2024, 17:58 Fabio Trabattoni @.***> wrote:
Could you provide some advice on how to debug this issue? Specifically, which important classes should I focus on, and where would be the best places to set breakpoints?
— Reply to this email directly, view it on GitHub https://github.com/zalando/logbook/issues/1485#issuecomment-2315738414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADI7HOMG2IC5FOTEKQHYUDZTXXTTAVCNFSM6AAAAABMWOGGYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJVG4ZTQNBRGQ . You are receiving this because you commented.Message ID: @.***>
DefaultHttpLogWriter
Turns out it works when trace is enabled. It is not picking up this setting:
write:
level: DEBUG
Could it be that this feature was removed at some point?
On Thu, Aug 29, 2024, 10:26 Fabio Trabattoni @.***> wrote:
DefaultHttpLogWriter
Turns out it works when trace is enabled. It is not picking up this setting:
write: level: DEBUG
— Reply to this email directly, view it on GitHub https://github.com/zalando/logbook/issues/1485#issuecomment-2317008022, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADI7HIVFI3XEURTMAT3BJLZT3LK3AVCNFSM6AAAAABMWOGGYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJXGAYDQMBSGI . You are receiving this because you commented.Message ID: @.***>
I am sure it was. I mean, I hope it was just moved somewhere else.
I'm following the documentation https://github.com/zalando/logbook#spring-boot-starter trying to make
WebClient
logging all exchanges, but here is a minimal code sample to make sure logbook + spring boot web client = nothing get loggedbuild.gradle.kts
:src/main/resources/application.yml
:SpringApplication.java
:As you can see, nothing got logged