How to disable some warnings in Spring Boot

Viewed 1137

in my app i can upload files (max size is 10MB). I created an exception handler for too big files, but console still shows warning that there was a try to upload too big file:

2020-09-30 01:38:59.306  WARN 2476 --- [nio-8080-exec-3] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (26937892) exceeds the configured maximum (10485760)]

Exception handler:

    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public void oversizedFilesHandler(MaxUploadSizeExceededException e){
        accountService.writeExceptionToFile(e);
    }

Is it possible to disable these warnings?

1 Answers

You can achieve that by adding log level to your properties file:

RULE : logging.level.xxxx=LEVEL

where:

  • LEVEL is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF.

  • xxxx is a package/class.

We apply the rule to your case:

logging.level.org.springframework.web=ERROR 

Or even thinner:

logging.level.org.springframework.web.multipart =ERROR 

Hence, only ERROR, FATAL and OFF level will be logged to you console.

Related