Java 类ch.qos.logback.classic.pattern.ThrowableProxyConverter 实例源码

项目:daikon    文件:LogbackJSONLayout.java   
private void handleThrown(ILoggingEvent loggingEvent) {
    if (loggingEvent.getThrowableProxy() != null) {

        if (loggingEvent.getThrowableProxy().getClassName() != null) {
            addEventData(LayoutFields.EXCEPTION_CLASS, loggingEvent.getThrowableProxy().getClassName());
        }

        if (loggingEvent.getThrowableProxy().getMessage() != null) {
            addEventData(LayoutFields.EXCEPTION_MESSAGE, loggingEvent.getThrowableProxy().getMessage());
        }

        ThrowableProxyConverter converter = new RootCauseFirstThrowableProxyConverter();
        converter.setOptionList(Arrays.asList("full"));
        converter.start();
        String stackTrace = converter.convert(loggingEvent);
        addEventData(LayoutFields.STACK_TRACE, stackTrace);
    }
}