@RestControllerAdvice
public class GlobalExceptionHandler {
private static Logger logger = LoggerFactory.getLogger(“error”);

@ExceptionHandler(value = Exception.class)
@ResponseBody
public Map<String, String> defaultErrorHandler(final HttpServletRequest request, final Exception ex) {
String requestURI = request.getRequestURI();
String exceptionStackTrace = ExceptionUtils.getStackTrace(ex);
logger.error("uri: {}, ex: {}", requestURI, exceptionStackTrace);

return ImmutableMap.of("uri", requestURI, "ex", exceptionStackTrace);
}

}