spring-cloud / spring-cloud/spring-cloud-openfeign

Allow configuring shouldLogRequestHeader/shouldLogResponseHeader

Open
#1,344 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
1.3k
Forks
838
Avg merge
2d 11h
Merged PRs (30d)
13

Description

**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);
          }
        };
      }
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing shouldLogRequestHeader and shouldLogResponseHeader methods and the Spring Cloud OpenFeign client configuration entry points. Add the four request and response include/exclude properties, then verify that excluded headers are omitted and that an include list limits logged headers when present.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
57/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.