is there a way to log exception for all @ExceptionHandler in one place

Viewed 126

I have @ControllerAdvice with numerous @ExceptionHandler methods with their own logic. However, I do need a log an original Exception. Is there a way to do it without adding explicit logging message to each @ExceptionHandler method?

1 Answers

No. You should define other Exception class and do not define it in @ControllerAdvice .

then you can use this Exception and put in log

       catch (DefinedException ex) {
            log.info("your log here");
            throw ex;
        } 
Related