protected ThrowableHandlingConverter createThrowableProxyConverter(LoggerContext context) { if (exceptionFormat == null) { return new RootCauseFirstThrowableProxyConverter(); } ThrowableHandlingConverter throwableHandlingConverter; if (exceptionFormat.isRootFirst()) { throwableHandlingConverter = new RootCauseFirstThrowableProxyConverter(); } else { throwableHandlingConverter = new ExtendedThrowableProxyConverter(); } List<String> options = new ArrayList<>(); // depth must be added first options.add(exceptionFormat.getDepth()); options.addAll(exceptionFormat.getEvaluators()); throwableHandlingConverter.setOptionList(options); throwableHandlingConverter.setContext(context); return throwableHandlingConverter; }
@Override protected void append(ILoggingEvent event) { if (event.getThrowableProxy() == null) { target.log(event.getFormattedMessage(), translate(event.getLevel())); } else { ExtendedThrowableProxyConverter throwableConverter = new ExtendedThrowableProxyConverter(); throwableConverter.start(); target.log(event.getFormattedMessage() + "\n" + throwableConverter.convert(event), translate(event.getLevel())); throwableConverter.stop(); } }
@Before public void setUp() throws Exception { lc.setPackagingDataEnabled(true); etpc.setContext(lc); etpc.start(); }
void verify(Throwable t) { t.printStackTrace(pw); ILoggingEvent le = createLoggingEvent(t); String result = etpc.convert(le); result = result.replace("common frames omitted", "more"); result = result.replaceAll(" ~?\\[.*\\]", ""); assertEquals(sw.toString(), result); }
LoggerContext loggerContext = (LoggerContext) context; if (loggerContext.isPackagingDataEnabled()) { exConverter = new ExtendedThrowableProxyConverter(); } else { exConverter = new ThrowableProxyConverter();
@Override protected void append(ILoggingEvent event) { if (event.getThrowableProxy() == null) { target.log(event.getFormattedMessage(), translate(event.getLevel())); } else { ExtendedThrowableProxyConverter throwableConverter = new ExtendedThrowableProxyConverter(); throwableConverter.start(); target.log(event.getFormattedMessage() + "\n" + throwableConverter.convert(event), translate(event.getLevel())); throwableConverter.stop(); } }
/** * This implementation checks if any of the converters in the chain handles * exceptions. If not, then this method adds a * {@link ExtendedThrowableProxyConverter} instance to the end of the chain. * <p> * This allows appenders using this layout to output exception information * event if the user forgets to add %ex to the pattern. Note that the * appenders defined in the Core package are not aware of exceptions nor * LoggingEvents. * <p> * If for some reason the user wishes to NOT print exceptions, then she can * add %nopex to the pattern. * * */ public void process(Converter<ILoggingEvent> head) { if(head == null) { // this should never happen throw new IllegalArgumentException("cannot process empty chain"); } if (!chainHandlesThrowable(head)) { Converter<ILoggingEvent> tail = ConverterUtil.findTail(head); Converter<ILoggingEvent> exConverter = new ExtendedThrowableProxyConverter(); tail.setNext(exConverter); } }
/** * This implementation checks if any of the converters in the chain handles * exceptions. If not, then this method adds a * {@link ExtendedThrowableProxyConverter} instance to the end of the chain. * <p> * This allows appenders using this layout to output exception information * event if the user forgets to add %ex to the pattern. Note that the * appenders defined in the Core package are not aware of exceptions nor * LoggingEvents. * <p> * If for some reason the user wishes to NOT print exceptions, then she can * add %nopex to the pattern. * * */ public void process(Converter<ILoggingEvent> head) { if(head == null) { // this should never happen throw new IllegalArgumentException("cannot process empty chain"); } if (!chainHandlesThrowable(head)) { Converter<ILoggingEvent> tail = ConverterUtil.findTail(head); Converter<ILoggingEvent> exConverter = new ExtendedThrowableProxyConverter(); tail.setNext(exConverter); } }
/** * This implementation checks if any of the converters in the chain handles * exceptions. If not, then this method adds a * {@link ExtendedThrowableProxyConverter} instance to the end of the chain. * <p> * This allows appenders using this layout to output exception information * event if the user forgets to add %ex to the pattern. Note that the * appenders defined in the Core package are not aware of exceptions nor * LoggingEvents. * <p> * If for some reason the user wishes to NOT print exceptions, then she can * add %nopex to the pattern. * * */ public void process(Converter<ILoggingEvent> head) { if (!chainHandlesThrowable(head)) { Converter<ILoggingEvent> tail = ConverterUtil.findTail(head); Converter<ILoggingEvent> exConverter = new ExtendedThrowableProxyConverter(); if (tail == null) { head = exConverter; } else { tail.setNext(exConverter); } } }
LoggerContext loggerContext = (LoggerContext) context; if (loggerContext.isPackagingDataEnabled()) { exConverter = new ExtendedThrowableProxyConverter(); } else { exConverter = new ThrowableProxyConverter();
LoggerContext loggerContext = (LoggerContext) context; if (loggerContext.isPackagingDataEnabled()) { exConverter = new ExtendedThrowableProxyConverter(); } else { exConverter = new ThrowableProxyConverter();
LoggerContext loggerContext = (LoggerContext) context; if (loggerContext.isPackagingDataEnabled()) { exConverter = new ExtendedThrowableProxyConverter(); } else { exConverter = new ThrowableProxyConverter();
LoggerContext loggerContext = (LoggerContext) context; if (loggerContext.isPackagingDataEnabled()) { exConverter = new ExtendedThrowableProxyConverter(); } else { exConverter = new ThrowableProxyConverter();