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

Debug logging but without body content #72

Closed
rhullah opened this issue Feb 20, 2024 · 5 comments · Fixed by darkweak/souin#461
Closed

Debug logging but without body content #72

rhullah opened this issue Feb 20, 2024 · 5 comments · Fixed by darkweak/souin#461

Comments

@rhullah
Copy link

rhullah commented Feb 20, 2024

While configuring caching, I like to see in the logs when a response is pulled from upstream, cached, and served from cache. I've been able to see this by configuring debug logging. But when I configure debug logging, it also logs the response body that was cached. For my API reverse proxied content, that can be handy (though I don't need it). But for my file asset reverse proxied content, it spams the logs with binary data.

Is there a way to configure logging to not include the body content? Or even more granular control of what logs body content (API requests) and what doesn't (file asset downloads)?

@darkweak
Copy link
Collaborator

darkweak commented Mar 5, 2024

Hello @rhullah, that's not possible. But I could totally remove the body from the logs for everyone. WDYT?

@francislavoie
Copy link
Member

IMO usually content length number is enough to signal "yep it's about the same as I expect". Could add a flag to also emit the body in a separate log entry or something. Possibly with a different logger name so it can be written out to a separate file.

@darkweak
Copy link
Collaborator

darkweak commented Mar 5, 2024

@francislavoie how do you do that?

@francislavoie
Copy link
Member

If you mean re logger name, with zap you can do .Named('foo') on a logger which appends a .foo to the logger name, essentially "namespacing" the logger. That way you can separate logs contextually from eachother. In Caddy you can configure loggers to include/exclude by logger name.

@rhullah
Copy link
Author

rhullah commented Mar 6, 2024

But I could totally remove the body from the logs for everyone.

IMO usually content length number is enough...

I'm my use-case I don't need the body and I don't think debug logging is something that should be regularly configured. But I don't want to speak to other's possible use-cases. If you want to get rid of it, Content-Length is a good alternative.

If you mean re logger name, with zap you can do .Named('foo') on a logger which appends a .foo to the logger name, essentially "namespacing" the logger. That way you can separate logs contextually from eachother. In Caddy you can configure loggers to include/exclude by logger name.

If this is doable I think it's a good solution as it puts the control into user choice and configuration.

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

Successfully merging a pull request may close this issue.

3 participants