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

DefaultExceptionHandler logs warning cannot be disabled [SPR-17628] #22159

spring-projects-issues opened this issue Dec 28, 2018 · 1 comment
in: web type: enhancement


Copy link

@spring-projects-issues spring-projects-issues commented Dec 28, 2018

danielrohe opened SPR-17628 and commented

Before the change the warn logger was not enabled for DefaultHandlerExceptionResolver and it only logged on warn level in case the exception was one of ConversionNotSupportedException, TypeMismatchException, HttpMessageNotReadableException, HttpMessageNotWritableException.

With the latest changes from #21916 the DefaultHandlerExceptionResolver warn logger got enabled by default in the constructor and can't be disabled (setting to null in Configuration class causes NPE). This leads to the state that all resolved exceptions are logged at warn level in AbstractHandlerExceptionResolver logException method. So not only the exceptions mentioned above but also HttpRequestMethodNotSupportedException, HttpMediaTypeNotSupportedException, HttpMediaTypeNotAcceptableException, MissingPathVariableException, MissingServletRequestParameterException, ServletRequestBindingException, MethodArgumentNotValidException, MissingServletRequestPartException, BindException, NoHandlerFoundException.

Can you please clarify what is the logging behavior of DefaultHandlerExceptionResolver?

In my opinion warn logging in this class should also be configurable and not enabled by default. So that developers are free to choose whether they want to have it disabled or enabled. As a side note: it should also honor the application property spring.mvc.log-resolved-exception

Affects: 5.1.3

@spring-projects-issues spring-projects-issues added type: bug status: waiting-for-triage in: web and removed type: bug labels Jan 11, 2019
@rstoyanchev rstoyanchev added this to the 5.1.5 milestone Jan 18, 2019
@rstoyanchev rstoyanchev added type: enhancement and removed status: waiting-for-triage labels Jan 18, 2019
@rstoyanchev rstoyanchev self-assigned this Jan 18, 2019
Copy link

@rstoyanchev rstoyanchev commented Jan 18, 2019

In #21714 DefaultHandlerExceptionResolver was updated to consistently log all exceptions. So that's expected behavior, but I'll fix the NPE so it can be disabled. Also you can use the protected method logException.

@rstoyanchev rstoyanchev changed the title DefaultExceptionHandler logs warnings for any exception [SPR-17628] DefaultExceptionHandler logs warning cannot be disabled [SPR-17628] Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: web type: enhancement
None yet

No branches or pull requests

2 participants