Skip to content

Support selective ErrorResponse logging #30565

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

Closed
mzeijen opened this issue May 31, 2023 · 3 comments
Closed

Support selective ErrorResponse logging #30565

mzeijen opened this issue May 31, 2023 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@mzeijen
Copy link

mzeijen commented May 31, 2023

As a user I would like to be able to easily log any ErrorResponse that is returned as response to a web request. This logging allows me to monitor which specific problems are returned and allows easier troubleshooting.

It should not matter where the ErrorResponse comes from, for instance thrown directly from a controller method, returned in an @ExceptionHandler (as a ErrorResponse or ProblemDetail), created by the ResponseEntityExceptionHandler, or any other way.

I would like to be able to filter which types of problems are logged. For instance, certain input validation problems are probably not interesting to log. Therefor a facility should be provided that allows me to configure which problems should be logged, and which shouldn’t. Preferably I should be able to use Spring environment properties to turn logging on for problems of a specific type (using the type field?)

I can imagine that not everybody wants to log ErrorResponse instances in the same way, for instance some might want different information in the log message or would prefer a specific log marker to be used. Therefor I propose that the code that does the actual logging can easily be replaced by custom logging logic.

Some default logging should be provided, and I suggest that the following ProblemDetail fields are in the log message: type, title, detail and status.

Note: I have discussed this feature request with @rstoyanchev at Spring I/O 2023

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 31, 2023
@rstoyanchev rstoyanchev self-assigned this Jun 15, 2023
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 15, 2023
@rstoyanchev rstoyanchev added this to the 6.1.x milestone Jun 15, 2023
@rstoyanchev
Copy link
Contributor

That'll be a good feature indeed. We'll explore some options to support it.

@rstoyanchev rstoyanchev changed the title Provide logging for ErrorResponse Provide support for selective logging of responses rendered from ErrorResponse Jun 15, 2023
@rstoyanchev rstoyanchev modified the milestones: 6.1.x, 6.1.2 Dec 5, 2023
@rstoyanchev rstoyanchev changed the title Provide support for selective logging of responses rendered from ErrorResponse Provide support for selective logging of ErrorResponse Dec 5, 2023
@rstoyanchev rstoyanchev changed the title Provide support for selective logging of ErrorResponse Support selective ErrorResponse logging Dec 5, 2023
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Dec 12, 2023

This is a bit more involved, so it will go into 6.2. I've created PR #31822 with the proposed changes. We don't have 6.2 snapshots yet, but as soon as we do I will set the target milestone on the PR and comment.

@rstoyanchev rstoyanchev closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
@rstoyanchev rstoyanchev added the status: superseded An issue that has been superseded by another label Dec 12, 2023
@rstoyanchev rstoyanchev removed this from the 6.1.2 milestone Dec 12, 2023
@mzeijen
Copy link
Author

mzeijen commented Dec 12, 2023

Fair enough. And good idea regarding the interception system, as we can build our logging solution on top of it.

Thanks for not forgetting about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants