Skip to content

Allow configuring shouldLogRequestHeader/shouldLogResponseHeader #1344

Description

@jkstrauss

**Suppressing specific headers is cumbersome **
Certain headers should probably not be logged, e.g., Authorization.

Add configuration properties to include/exclude headers
Add the following list configurations:

  • spring.cloud.openfeign.client.config.name.headers.request.include
  • spring.cloud.openfeign.client.config.name.headers.request.exclude
  • spring.cloud.openfeign.client.config.name.headers.response.include
  • spring.cloud.openfeign.client.config.name.headers.response.exclude

The expected behavior would be to exclude any header in the exclude list, and only show header in the include list if any are present.

Alternatives: Making a custom component

@Component
    class MyFeignLoggerFactory implements FeignLoggerFactory {
      @Override
      public Logger create(Class<?> type) {
        return new Slf4jLogger(type) {
          @Override
          protected boolean shouldLogRequestHeader(String header) {
            return !"Authorization".equals(header);
          }
        };
      }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions