ch.qos.logback.classic.spi.StackTraceElementProxy Java Examples
The following examples show how to use
ch.qos.logback.classic.spi.StackTraceElementProxy.
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: 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 #2
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 #3
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 #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: 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 #6
Source File: ExceptionConverter.java From styx with Apache License 2.0 | 5 votes |
private String getExceptionData(final ILoggingEvent loggingEvent) { IThrowableProxy throwableProxy = loggingEvent.getThrowableProxy(); StackTraceElementProxy loggableStackTraceElement = findFirstStackTraceElementForClasses(throwableProxy, readStyxClassesFromProperty()) .orElse(getTopStackTraceElement(throwableProxy)); return Optional.ofNullable(loggableStackTraceElement) .map(ExceptionConverter::createExceptionMessage) .orElse(NO_MSG); }
Example #7
Source File: LoghubAppender.java From aliyun-log-logback-appender with Apache License 2.0 | 5 votes |
private String fullDump(StackTraceElementProxy[] stackTraceElementProxyArray) { StringBuilder builder = new StringBuilder(); for (StackTraceElementProxy step : stackTraceElementProxyArray) { builder.append(CoreConstants.LINE_SEPARATOR); String string = step.toString(); builder.append(CoreConstants.TAB).append(string); ThrowableProxyUtil.subjoinPackagingData(builder, step); } return builder.toString(); }
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: RollbarAppender.java From rollbar-java with MIT License | 5 votes |
private StackTraceElement[] buildStackTraceElements(StackTraceElementProxy[] stackTraceElements) { StackTraceElement[] elements = new StackTraceElement[stackTraceElements.length]; for (int i = 0; i < stackTraceElements.length; i++) { elements[i] = stackTraceElements[i].getStackTraceElement(); } return elements; }
Example #13
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 #14
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 #15
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 #16
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 #17
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 #18
Source File: PrefixedExtendedThrowableProxyConverter.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override protected void extraData(StringBuilder builder, StackTraceElementProxy step) { if (step != null) { ThrowableProxyUtil.subjoinPackagingData(builder, step); } }
Example #19
Source File: ExceptionConverter.java From styx with Apache License 2.0 | 4 votes |
private static String createExceptionMessage(StackTraceElementProxy loggableStackTraceElement) { String exceptionClass = loggableStackTraceElement.getStackTraceElement().getClassName(); String exceptionMethod = loggableStackTraceElement.getStackTraceElement().getMethodName(); String exceptionID = hashCodeForException(exceptionClass, exceptionMethod); return MessageFormat.format(SPLUNK_FRIENDLY_LOG_MESSAGE_TEMPLATE, exceptionClass, exceptionMethod, exceptionID); }
Example #20
Source File: MetricsLogAppenderTests.java From pravega with Apache License 2.0 | 4 votes |
@Override public StackTraceElementProxy[] getStackTraceElementProxyArray() { return new StackTraceElementProxy[0]; }
Example #21
Source File: LogbackQiniuAppender.java From qiniu-logging-plugin with BSD 2-Clause "Simplified" License | 4 votes |
protected void append(ILoggingEvent logEvent) { Point point = new Point(); point.append("timestamp", logEvent.getTimeStamp()); point.append("level", logEvent.getLevel().toString()); point.append("logger", logEvent.getLoggerName()); if (logEvent.getMarker() != null) { point.append("marker", logEvent.getMarker().toString()); } else { point.append("marker", ""); } point.append("message", logEvent.getMessage()); point.append("thread_name", logEvent.getThreadName()); point.append("thread_id", 0); // logback doest not support thread id point.append("thread_priority", 0); if (logEvent.getThrowableProxy() != null) { StringBuilder exceptionBuilder = new StringBuilder(); exceptionBuilder.append(logEvent.getThrowableProxy().getMessage()).append("\n"); for (StackTraceElementProxy proxy : logEvent.getThrowableProxy().getStackTraceElementProxyArray()) { exceptionBuilder.append(proxy.getStackTraceElement().toString()).append("\n"); } point.append("exception", exceptionBuilder.toString()); } else { point.append("exception", ""); } //lock this.rwLock.lock(); if (!batch.canAdd(point)) { final byte[] postBody = batch.toString().getBytes(Constants.UTF_8); try { this.executorService.execute(new Runnable() { public void run() { try { Response response = logPushSender.send(postBody); response.close(); } catch (QiniuException e) { //e.printStackTrace(); guard.write(postBody); } } }); } catch (RejectedExecutionException ex) { guard.write(postBody); } batch.clear(); } batch.add(point); this.rwLock.unlock(); }
Example #22
Source File: PrefixedExtendedThrowableProxyConverter.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override protected void extraData(StringBuilder builder, StackTraceElementProxy step) { if (step != null) { ThrowableProxyUtil.subjoinPackagingData(builder, step); } }
Example #23
Source File: ExceptionConverter.java From styx with Apache License 2.0 | 4 votes |
private Optional<StackTraceElementProxy> findFirstStackTraceElementForClasses(final IThrowableProxy throwableProxy, final String[] targetClasses) { return StreamSupport.stream(collectThrowableProxies(throwableProxy).spliterator(), false) .flatMap(proxy -> proxy != null ? Arrays.stream(proxy.getStackTraceElementProxyArray()) : Stream.empty()) .filter(steProxy -> contains(steProxy.getSTEAsString(), targetClasses)) .findFirst(); }