Java Code Examples for ch.qos.logback.classic.spi.IThrowableProxy#getStackTraceElementProxyArray()
The following examples show how to use
ch.qos.logback.classic.spi.IThrowableProxy#getStackTraceElementProxyArray() .
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: LogFilter.java From DimpleBlog with Apache License 2.0 | 6 votes |
@Override public FilterReply decide(ILoggingEvent event) { StringBuilder exception = new StringBuilder(); IThrowableProxy iThrowableProxy1 = event.getThrowableProxy(); if (iThrowableProxy1 != null) { exception.append("<span class='excehtext'>" + iThrowableProxy1.getClassName() + " " + iThrowableProxy1.getMessage() + "</span></br>"); for (int i = 0; i < iThrowableProxy1.getStackTraceElementProxyArray().length; i++) { exception.append("<span class='excetext'>" + iThrowableProxy1.getStackTraceElementProxyArray()[i].toString() + "</span></br>"); } } LoggerMessage loggerMessage = new LoggerMessage( event.getMessage() , DateFormat.getDateTimeInstance().format(new Date(event.getTimeStamp())), event.getThreadName(), event.getLoggerName(), event.getLevel().levelStr, exception.toString(), "" ); LoggerQueue.getInstance().push(loggerMessage); return FilterReply.ACCEPT; }
Example 2
Source File: PrefixedThrowableProxyConverter.java From bither-desktop-java with Apache License 2.0 | 6 votes |
void subjoinThrowableProxy(StringBuilder buf, IThrowableProxy tp) { subjoinFirstLine(buf, tp); buf.append(CoreConstants.LINE_SEPARATOR); final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); final int commonFrames = tp.getCommonFrames(); int maxIndex = stepArray.length; if (commonFrames > 0) { maxIndex -= commonFrames; } for (int i = 0; i < maxIndex; i++) { final String string = stepArray[i].toString(); buf.append(PREFIX); buf.append(string); extraData(buf, stepArray[i]); // allow other data to be added buf.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0) { buf.append("!... ").append(tp.getCommonFrames()).append( " common frames omitted").append(CoreConstants.LINE_SEPARATOR); } }
Example 3
Source File: StructuredLoggingEncoder.java From flo with Apache License 2.0 | 6 votes |
private static void writeStack(StringBuilder sb, IThrowableProxy t, String caption, int indent, String linebreak) { if (t == null) { return; } indent(sb, indent).append(caption).append(t.getClassName()).append(": ").append(t.getMessage()).append(linebreak); final StackTraceElementProxy[] trace = t.getStackTraceElementProxyArray(); if (trace != null) { int commonFrames = t.getCommonFrames(); int printFrames = trace.length - commonFrames; for (int i = 0; i < printFrames; i++) { indent(sb, indent).append("\t").append(trace[i]).append(linebreak); } if (commonFrames != 0) { indent(sb, indent).append("\t... ").append(commonFrames).append(" more").append(linebreak); } final IThrowableProxy[] suppressed = t.getSuppressed(); for (IThrowableProxy st : suppressed) { writeStack(sb, st, "Suppressed: ", indent + 1, linebreak); } } writeStack(sb, t.getCause(), "Caused by: ", indent, linebreak); }
Example 4
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 5
Source File: PrefixedThrowableProxyConverter.java From bither-desktop-java with Apache License 2.0 | 6 votes |
void subjoinThrowableProxy(StringBuilder buf, IThrowableProxy tp) { subjoinFirstLine(buf, tp); buf.append(CoreConstants.LINE_SEPARATOR); final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); final int commonFrames = tp.getCommonFrames(); int maxIndex = stepArray.length; if (commonFrames > 0) { maxIndex -= commonFrames; } for (int i = 0; i < maxIndex; i++) { final String string = stepArray[i].toString(); buf.append(PREFIX); buf.append(string); extraData(buf, stepArray[i]); // allow other data to be added buf.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0) { buf.append("!... ").append(tp.getCommonFrames()).append( " common frames omitted").append(CoreConstants.LINE_SEPARATOR); } }
Example 6
Source File: IntegrationPostHandler.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private String parseException(ILoggingEvent eventObject2){ if (eventObject.getThrowableProxy() != null) { StringBuilder sbException = new StringBuilder(); IThrowableProxy throwableProxy = eventObject.getThrowableProxy(); sbException.append("```\n"); StackTraceElementProxy[] st = throwableProxy.getStackTraceElementProxyArray(); for (int j = 0; j < st.length; j++) { StackTraceElementProxy stackTraceElementProxy = st[j]; StackTraceElement stackTraceElement = stackTraceElementProxy.getStackTraceElement(); sbException.append(stackTraceElement + "\n"); if (j == 5) { break; } } sbException.append("```"); return sbException.toString(); } return null; }
Example 7
Source File: NSThrowableConvert.java From ns4_frame with Apache License 2.0 | 5 votes |
@Override public void subjoinSTEPArray(StringBuilder buf, int indent, IThrowableProxy tp) { String totalKey = LogKey.getTotalKey(); StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); int commonFrames = tp.getCommonFrames(); boolean unrestrictedPrinting = Integer.MAX_VALUE > stepArray.length; int maxIndex = (unrestrictedPrinting) ? stepArray.length : Integer.MAX_VALUE; if (commonFrames > 0 && unrestrictedPrinting) { maxIndex -= commonFrames; } for (int i = 0; i < maxIndex; i++) { buf.append(totalKey); ThrowableProxyUtil.indent(buf, indent); buf.append(stepArray[i]); extraData(buf, stepArray[i]); // allow other data to be added buf.append(CoreConstants.LINE_SEPARATOR); } if (commonFrames > 0 && unrestrictedPrinting) { buf.append(totalKey); ThrowableProxyUtil.indent(buf, indent); buf.append("... ").append(tp.getCommonFrames()).append( " common frames omitted").append(CoreConstants.LINE_SEPARATOR); } }
Example 8
Source File: ExceptionUtil.java From cloudwatch-logback-appender with Apache License 2.0 | 5 votes |
private static void appendStackTrace(StringBuilder sb, String prefix, IThrowableProxy aProxy) { StackTraceElementProxy[] frames = aProxy.getStackTraceElementProxyArray(); int commonFrames = aProxy.getCommonFrames(); for(int i=0, size=frames.length-commonFrames; i<size; ++i) { sb.append(prefix+frames[i]+"\n"); } if (commonFrames>0) { sb.append(prefix+"... "+commonFrames+" more"+"\n"); } }
Example 9
Source File: ExceptionConverter.java From styx with Apache License 2.0 | 5 votes |
private StackTraceElementProxy getTopStackTraceElement(final IThrowableProxy throwableProxy) { StackTraceElementProxy stackTraceLine = null; StackTraceElementProxy[] stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray(); if (stackTraceElementProxyArray != null && stackTraceElementProxyArray.length > 0) { stackTraceLine = stackTraceElementProxyArray[0]; } return stackTraceLine; }
Example 10
Source File: CloudwatchLogsLogbackAppender.java From cloudwatchlogs-java-appender with Apache License 2.0 | 5 votes |
private String dump(IThrowableProxy throwableProxy) { StringBuilder builder = new StringBuilder(); builder.append(throwableProxy.getClassName()).append(": ").append(throwableProxy.getMessage()).append(CoreConstants.LINE_SEPARATOR); for (StackTraceElementProxy step : throwableProxy.getStackTraceElementProxyArray()) { String string = step.toString(); builder.append(CoreConstants.TAB).append(string); ThrowableProxyUtil.subjoinPackagingData(builder, step); builder.append(CoreConstants.LINE_SEPARATOR); } return builder.toString(); }
Example 11
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 12
Source File: LogbackUtil.java From otroslogviewer with Apache License 2.0 | 5 votes |
public static void addException(IThrowableProxy throwableProxy, String message, LogDataBuilder builder) { if (throwableProxy != null) { StringBuilder sb = new StringBuilder(); sb.append(message).append("\n"); sb.append(throwableProxy.getClassName()).append(": ").append(throwableProxy.getMessage()).append("\n"); for (StackTraceElementProxy stackTraceElementProxy : throwableProxy.getStackTraceElementProxyArray()) { sb.append("\t").append(stackTraceElementProxy.getSTEAsString()).append("\n"); } builder.withMessage(sb.toString()); } }
Example 13
Source File: LogWatcher.java From brooklyn-server with Apache License 2.0 | 5 votes |
public static Predicate<ILoggingEvent> containsExceptionStackLine(final Class<?> clazz, final String methodName) { return event -> { IThrowableProxy throwable = (event != null) ? event.getThrowableProxy() : null; if (throwable != null) { for (StackTraceElementProxy line : throwable.getStackTraceElementProxyArray()) { if (line.getStackTraceElement().getClassName().contains(clazz.getSimpleName()) && line.getStackTraceElement().getMethodName().contains(methodName)) { return true; } } } return false; }; }
Example 14
Source File: LogWatcher.java From brooklyn-server with Apache License 2.0 | 5 votes |
public void printEvents(PrintStream stream, Iterable<? extends ILoggingEvent> events) { for (ILoggingEvent event : events) { stream.println(Time.makeDateString(event.getTimeStamp()) + ": " + event.getThreadName() + ": " + event.getLevel() + ": " + event.getMessage()); IThrowableProxy throwable = event.getThrowableProxy(); if (throwable != null) { stream.println("\t" + throwable.getMessage()); if (throwable.getStackTraceElementProxyArray() != null) { for (StackTraceElementProxy element : throwable.getStackTraceElementProxyArray()) { stream.println("\t\t" + "at " + element); } } } } }
Example 15
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); } }
Example 16
Source File: LoggingEventMatcher.java From styx with Apache License 2.0 | 4 votes |
@Override protected boolean matchesSafely(IThrowableProxy item) { return exceptionClass.equals(item.getClassName()) && exceptionMessage.matches(item.getMessage().replace(System.lineSeparator(), "")) && item.getStackTraceElementProxyArray().length > 0; }