io.undertow.servlet.ExceptionLog Java Examples

The following examples show how to use io.undertow.servlet.ExceptionLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuarkusExceptionHandler.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleThrowable(HttpServerExchange exchange, ServletRequest request, ServletResponse response, Throwable t) {
    String uid = BASE_ID + ERROR_COUNT.incrementAndGet();
    request.setAttribute(ERROR_ID, uid);
    ExceptionLog log = t.getClass().getAnnotation(ExceptionLog.class);
    if (log != null) {
        Logger.Level level = log.value();
        Logger.Level stackTraceLevel = log.stackTraceLevel();
        String category = log.category();
        handleCustomLog(exchange, t, level, stackTraceLevel, category, uid);
    } 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 %s to %s", uid, exchange.getRequestURI());
    } else {
        UndertowLogger.REQUEST_IO_LOGGER.errorf(t, "Exception handling request %s to %s", uid, exchange.getRequestURI());
    }
    return false;
}