zalando/logbook

Allow using multiple strategies for multiple set of paths

Opened this issue · 3 comments

Detailed Description

Allowing multiple strategies to work alongside each other for different situations. For example one strategy to work for a set of paths, conditions and/or filters, while having another strategy for different paths and conditions.

Context

We have a requirement to log request and response for certain paths regardless of the status of the response. So I use include to log these paths by using the default strategy. However, there are some paths which doesn't need to be logged unless an error happens. In which case we need to see what was the request body or param that lead to this error.

I know status-at-least or body-only-if-status-at-least exist but there's no way to have both the default and one of the two mentioned strategies together. I tried to work this out with filters and other configs but had no success.

Your Environment

  • Version used: 3.9.0
  • Using logbook-spring-boot-webflux-autoconfigure with Spring WebFlux

@whiskeysierra How would I approach your suggestion? Could you give me a rough example?

By the way I guess it doesn't have to be a new strategy. It could be a new kind of Predicate which accepts minimum status as parameter.
Something like this:

  predicate:
    include:
      - path: /test/logged
        methods:
          - POST
        min-status: 400