ExceptionLog log = t.getClass().getAnnotation(ExceptionLog.class);
if(log != null) {
Logger.Level level = log.value();
Logger.Level stackTraceLevel = log.stackTraceLevel();
String category = log.category();
BasicLogger logger = UndertowLogger.REQUEST_LOGGER;
if(!category.isEmpty()) {
logger = Logger.getLogger(category);
}
boolean stackTrace = true;
if(stackTraceLevel.ordinal() > level.ordinal()) {
if(!logger.isEnabled(stackTraceLevel)) {
stackTrace = false;
}
}
if(stackTrace) {
logger.logf(level, t, "Exception handling request to %s", exchange.getRequestURI());
} else {
logger.logf(level, "Exception handling request to %s: %s", exchange.getRequestURI(), t.getMessage());
}
} else if(t instanceof IOException) {
//we log IOExceptions at a lower level
//because they can be easily caused by malicious remote clients in at attempt to DOS the server by filling the logs
UndertowLogger.REQUEST_IO_LOGGER.debugf(t, "Exception handling request to %s", exchange.getRequestURI());