I created ExcpetionHandler class which annotated with @ControllerAdivce
annotation which working fine using eclipse tomcat server.
While I build the project and deploy it to tomcat on some unix machine , the exceptionHandler not getting triggerd.
I noticed that some log4j warning getting generated only on the unix machine .
The log4j xml is configured and all appenders are working .
Only after adding the below class I start to get the below log4j messages.
Any idea ?
@ControllerAdvice
public class ExceptionController {
@ExceptionHandler(RuntimeException.class)
public ResponseEntity<ClientErrorMessage> handleRunTimeException(HttpServletRequest request, RuntimeException exception) {
ClientErrorMessage message = SOME_MESSAGE
return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
log4j:WARN No appenders could be found for logger (org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.