Skip to content
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

Disable LogbookExchangeFilterFunction logging based on logbook property #1866

Open
aldex32 opened this issue Jul 4, 2024 · 1 comment
Open
Labels

Comments

@aldex32
Copy link

aldex32 commented Jul 4, 2024

I would like to have a logbook property where I can both disable servlet filters but also LogbookExchangeFilterFunction. Seems like logbook.filter.enabled property is only intended for servlet filter support as far as I can see in LogbookAutoConfiguration. Can this property also be used for http client logging?

Detailed Description

I am using [email protected] together with [email protected]. And when I set logbook.filter.enabled=false, only the servlet logging gets disabled, but the WebClient logging still occurs. I am not sure if this is as by design or is a bug.

Context

This is important because users of this library can use a single property to enable/disable request/response logging. And since LogbookExchangeFilterFunction requires a logbook bean which is autoconfigured based on properties, why not leveraging the property to disable/enable the logging.

Your Environment

  • Version used: 3.9.0
@aldex32 aldex32 added the Feature label Jul 4, 2024
@adityachaudhari24
Copy link

I've recently integrated LogBook into our Spring Boot project. My goal was to enable logging specifically for WebFlux without affecting all Spring Boot requests and responses.

Here's what I did:

  1. Added the LogBook dependency for WebFlux in build.gradle.kts:
    implementation("org.zalando:logbook-spring-webflux:3.9.0")
    
  2. Configured the logbook.filter.enabled property in application.properties`
  3. initialize the LogBook bean and hooked that in LogbookExchangeFilterFunction filters.

Observations:

  1. Simply adding the dependency org.zalando:logbook-spring-webflux:3.9.0 was sufficient to instantiate the LogBook instance.
  2. Using LogbookExchangeFilterFunction, I was able to log requests and responses for my WebClient.
  3. The property logbook.filter.enabled=true seems to have no impact on enabling or disabling the logging functionality.

In summary, just adding the LogBook WebFlux dependency was enough to get logging working for WebClient without needing additional configurations however logbook.filter.enabled property does not have any impact on ON/OFF logbook webflux logging.
here is my demo project for reference : https://github.com/adityachaudhari24/logbook-demos/blob/master/src/main/resources/application.properties .

Thanks @aldex32 for opening the feature,
Something similar I am looking, where just by property logbook.filter.enabled disable my logbook filters in the webflix must stop logging.
l want to upvote this feature, I will try to contribute on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants