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

requestContent and responseContent always return "-" in request log #2045

Closed
Wstunes opened this issue May 4, 2017 · 6 comments
Closed

requestContent and responseContent always return "-" in request log #2045

Wstunes opened this issue May 4, 2017 · 6 comments

Comments

@Wstunes
Copy link

@Wstunes Wstunes commented May 4, 2017

the request log config in my config.yaml is like the following

 requestLog:
    appenders:
      - type: file
        currentLogFilename: ./logs/runtimeService-requests.log
        archive: true
        archivedLogFilenamePattern: "./logs/runtimeService-requests-%i.log.gz"
        logFormat: "%h|%t{yyyy/MM/dd HH:mm:ss}|%D|%i{requestContent}|%i{responseContent}"
        maxFileSize: 5M
        archivedFileCount: 10

But output of the requestContent and responseContent is always "-"
I am following the logback instruction here https://logback.qos.ch/manual/layouts.html#AccessPatternLayout
Am I missing some configuration?
Or is there some way to format the request log via code?
Thanks

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 4, 2017

@Wstunes The logFormat is incorrect. Correct as follows:

logFormat: "%h|%t{yyyy/MM/dd HH:mm:ss}|%D|%requestContent|%responseContent"

In addition, it is necessary to register TeeFilter as follows.

environment.servlets().addFilter("teeFilter", TeeFilter.class).addMappingForUrlPatterns(null, false, "/*");
@Wstunes

This comment has been minimized.

Copy link
Author

@Wstunes Wstunes commented May 4, 2017

@t-tsutsumi
Thanks a lot. It works.
But the request and response content are splited into multiple lines.
Is there some way to format the request log programatically because I may want to filter something

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 4, 2017

@Wstunes There are several solutions; but perhaps extend the TeeFilter is easiest.

@nickbabcock

This comment has been minimized.

Copy link
Contributor

@nickbabcock nickbabcock commented Jun 20, 2017

Closing this as the question appears answered. If not, please respond to re-open.

Thank you @t-tsutsumi for the great insight

@cwagnello

This comment has been minimized.

Copy link

@cwagnello cwagnello commented Jan 9, 2019

I know this issue is closed but how is anyone supposed to know that they need to add a TeeFilter? Or is this fixed in newer versions of Dropwizard?

@nickbabcock

This comment has been minimized.

Copy link
Contributor

@nickbabcock nickbabcock commented Jan 10, 2019

I've made a PR to document this in #2596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.