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

Add option to log headers to AbstractRequestLoggingFilter [SPR-14245]

Closed
spring-projects-issues opened this issue May 4, 2016 · 0 comments
Assignees
Labels
in: web type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 4, 2016

M. Justin opened SPR-14245 and commented

AbstractRequestLoggingFilter has options to include the query string and the payload. It would be nice if it also had a standard option to log the request headers.

The rationale here is that sometimes it is helpful or necessary to know what the request headers were in order to troubleshoot an issue.

A workaround is to override the "createMessage" method to append the header information:

@Bean
public Filter logFilter() {
    CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter() {
        @Override
        protected String createMessage(HttpServletRequest request, String prefix, String suffix) {
            return super.createMessage(request, prefix, suffix)
                    + ";headers=" + new ServletServerHttpRequest(request).getHeaders();
        }
    };
    return filter;
}

Note though that since the name of the logger that is used is based on the name of the class, the logging configuration has to be set to log the new subclass to DEBUG, not e.g. CommonsRequestLoggingFilter.


Issue Links:

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

No branches or pull requests

2 participants