Java Code Examples for ch.qos.logback.classic.spi.IThrowableProxy#getCause()
The following examples show how to use
ch.qos.logback.classic.spi.IThrowableProxy#getCause() .
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: ExceptionUtil.java From cloudwatch-logback-appender with Apache License 2.0 | 6 votes |
private static void appendProxy(StringBuilder sb, String aPrefix, String aHeader, IThrowableProxy aException) { sb.append(aPrefix + aHeader + aException.getClassName() + ": " +aException.getMessage() + "\n"); String prefix = aPrefix+"\t"; appendStackTrace(sb, prefix, aException); IThrowableProxy[] suppressed = aException.getSuppressed(); if(suppressed!=null) { for(IThrowableProxy supp : suppressed) { if(supp!=null) { appendProxy(sb, prefix, "Suppressed: ", supp); } } } IThrowableProxy cause = aException.getCause(); if(cause!=null) { appendProxy(sb, prefix, "Causd by: ", cause); } }
Example 2
Source File: CollectorLogbackAppender.java From glowroot with Apache License 2.0 | 6 votes |
private static Proto.Throwable toProto(IThrowableProxy t) { Proto.Throwable.Builder builder = Proto.Throwable.newBuilder() .setClassName(t.getClassName()); String message = t.getMessage(); if (message != null) { builder.setMessage(message); } for (StackTraceElementProxy element : t.getStackTraceElementProxyArray()) { builder.addStackTraceElement(ErrorMessage.toProto(element.getStackTraceElement())); } builder.setFramesInCommonWithEnclosing(t.getCommonFrames()); IThrowableProxy cause = t.getCause(); if (cause != null) { builder.setCause(toProto(cause)); } for (IThrowableProxy suppressed : t.getSuppressed()) { builder.addSuppressed(toProto(suppressed)); } return builder.build(); }
Example 3
Source File: ExpectedExceptionAppender.java From centraldogma with Apache License 2.0 | 5 votes |
@Nullable private static IThrowableProxy getException(ILoggingEvent event) { final IThrowableProxy throwableProxy = event.getThrowableProxy(); if (throwableProxy != null) { final IThrowableProxy cause = throwableProxy.getCause(); if (cause != null) { return cause; } } return null; }
Example 4
Source File: ExceptionConverter.java From styx with Apache License 2.0 | 5 votes |
private Iterable<IThrowableProxy> collectThrowableProxies(final IThrowableProxy throwableProxy) { IThrowableProxy[] throwableProxyArray = new IThrowableProxy[MAXIMUM_ALLOWED_DEPTH]; IThrowableProxy actualThrowableProxy = throwableProxy; for (int i = 0; i < throwableProxyArray.length; i++) { if (actualThrowableProxy != null) { throwableProxyArray[i] = actualThrowableProxy; actualThrowableProxy = actualThrowableProxy.getCause(); } else { break; } } return asList(throwableProxyArray); }
Example 5
Source File: CloudwatchLogsLogbackAppender.java From cloudwatchlogs-java-appender with Apache License 2.0 | 5 votes |
@Override protected void append(ILoggingEvent event) { StringBuilder message = new StringBuilder(event.getFormattedMessage()); IThrowableProxy throwableProxy = event.getThrowableProxy(); while (throwableProxy != null) { message.append("\n").append(dump(throwableProxy)); throwableProxy = throwableProxy.getCause(); if (throwableProxy != null) { message.append("\nCaused by:"); } } String account = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.ACCOUNT); String action = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.ACTION); String user = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.USER); String session = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.SESSION); String request = event.getMDCPropertyMap().get(CloudwatchLogsMDCPropertyNames.REQUEST); Marker marker = event.getMarker(); String eventId = marker == null ? null : marker.getName(); Map<String, String> customMdcAttributes = new HashMap<>(); for (String key : config.getCustomMdcKeys()) { String value = event.getMDCPropertyMap().get(key); if (value != null) { customMdcAttributes.put(key, value); } } CloudwatchLogsLogEvent logEvent = new CloudwatchLogsLogEvent(event.getLevel().toString(), event.getLoggerName(), eventId, message.toString(), event.getTimeStamp(), event.getThreadName(), account, action, user, session, request, customMdcAttributes); while (!eventQueue.offer(logEvent)) { // Discard old logging messages while queue is full. eventQueue.poll(); discardedCount.incrementAndGet(); } processedCount.incrementAndGet(); }
Example 6
Source File: DefaultLogThrowable.java From twill with Apache License 2.0 | 5 votes |
DefaultLogThrowable(IThrowableProxy throwableProxy) { this.className = throwableProxy.getClassName(); this.message = throwableProxy.getMessage(); StackTraceElementProxy[] stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray(); this.stackTraces = new StackTraceElement[stackTraceElementProxyArray.length]; for (int i = 0; i < stackTraceElementProxyArray.length; i++) { stackTraces[i] = stackTraceElementProxyArray[i].getStackTraceElement(); } cause = (throwableProxy.getCause() == null) ? null : new DefaultLogThrowable(throwableProxy.getCause()); }
Example 7
Source File: GelfEncoder.java From logback-gelf with GNU Lesser General Public License v2.1 | 5 votes |
private IThrowableProxy getRootException(final IThrowableProxy throwableProxy) { if (throwableProxy == null) { return null; } IThrowableProxy rootCause = throwableProxy; while (rootCause.getCause() != null) { rootCause = rootCause.getCause(); } return rootCause; }
Example 8
Source File: MetricsLogAppender.java From pravega with Apache License 2.0 | 5 votes |
private void recordEvent(String metricName, ILoggingEvent event) { IThrowableProxy p = event.getThrowableProxy(); while (shouldUnwrap(p)) { p = p.getCause(); } DYNAMIC_LOGGER.recordMeterEvents(metricName, 1, MetricsTags.exceptionTag(event.getLoggerName(), p == null ? null : p.getClassName())); }
Example 9
Source File: MetricsLogAppender.java From pravega with Apache License 2.0 | 5 votes |
private boolean shouldUnwrap(IThrowableProxy p) { // Most of our exceptions are wrapped in CompletionException or ExecutionException. Since these are not very useful // in terms of determining the root cause, we should unwrap them to get to the actual exception that caused the event. return p != null && p.getCause() != null && (p.getClassName().endsWith(COMPLETION_EXCEPTION_NAME) || p.getClassName().endsWith(EXECUTION_EXCEPTION_NAME)); }
Example 10
Source File: PrefixedThrowableProxyConverter.java From bither-desktop-java with Apache License 2.0 | 5 votes |
@Override protected String throwableProxyToString(IThrowableProxy tp) { final StringBuilder buf = new StringBuilder(32); IThrowableProxy currentThrowable = tp; while (currentThrowable != null) { subjoinThrowableProxy(buf, currentThrowable); currentThrowable = currentThrowable.getCause(); } return buf.toString(); }
Example 11
Source File: PrefixedThrowableProxyConverter.java From bither-desktop-java with Apache License 2.0 | 5 votes |
@Override protected String throwableProxyToString(IThrowableProxy tp) { final StringBuilder buf = new StringBuilder(32); IThrowableProxy currentThrowable = tp; while (currentThrowable != null) { subjoinThrowableProxy(buf, currentThrowable); currentThrowable = currentThrowable.getCause(); } return buf.toString(); }
Example 12
Source File: MillisecondPrecisionSyslogAppender.java From logging-java with Apache License 2.0 | 5 votes |
private void recursiveWrite( final OutputStream sw, final String stackTracePrefix, final IThrowableProxy tp, final int indent, final String firstLinePrefix) { final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); try { handleThrowableFirstLine(sw, tp, stackTracePrefix, indent, firstLinePrefix); for (final StackTraceElementProxy step : stepArray) { final StringBuilder sb = new StringBuilder(); sb.append(stackTracePrefix); addIndent(sb, indent); sb.append(step); sw.write(sb.toString().getBytes()); sw.flush(); } } catch (IOException e) { return; } final IThrowableProxy[] suppressed = tp.getSuppressed(); if (suppressed != null) { for (final IThrowableProxy current : suppressed) { recursiveWrite(sw, stackTracePrefix, current, indent + 1, CoreConstants.SUPPRESSED); } } final IThrowableProxy cause = tp.getCause(); if (cause != null) { recursiveWrite(sw, stackTracePrefix, cause, indent, CoreConstants.CAUSED_BY); } }