本文整理汇总了Java中ch.qos.logback.classic.spi.IThrowableProxy.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java IThrowableProxy.getCause方法的具体用法?Java IThrowableProxy.getCause怎么用?Java IThrowableProxy.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.spi.IThrowableProxy
的用法示例。
在下文中一共展示了IThrowableProxy.getCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendThrowable
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private void appendThrowable(IThrowableProxy proxy, ILoggingEvent loggingEvent) {
//Append Exception Message
appendToLog(loggingEvent, String.format("%s: %s", proxy.getClassName(), proxy.getMessage()));
//Append Exception Stack Trace
for (StackTraceElementProxy element : loggingEvent.getThrowableProxy().getStackTraceElementProxyArray()) {
appendToLog(loggingEvent, "\t" + element.getSTEAsString());
}
if (proxy.getSuppressed().length > 0) {
appendToLog(loggingEvent, "Suppressed Exceptions:");
for (IThrowableProxy p : proxy.getSuppressed()) {
appendThrowable(p, loggingEvent);
}
}
if (proxy.getCause() != null) {
appendToLog(loggingEvent, "Cause:");
appendThrowable(proxy.getCause(), loggingEvent);
}
}
示例2: recursiveAppendRootCauseFirst
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
protected void recursiveAppendRootCauseFirst(StringBuilder sb, String prefix, int indent, IThrowableProxy tp) {
if (tp.getCause() != null) {
recursiveAppendRootCauseFirst(sb, prefix, indent, tp.getCause());
prefix = null; // to avoid adding it more than once
}
ThrowableProxyUtil.indent(sb, indent - 1);
if (prefix != null) {
sb.append(prefix);
}
ThrowableProxyUtil.subjoinFirstLineRootCauseFirst(sb, tp);
sb.append(CoreConstants.LINE_SEPARATOR);
subjoinSTEPArray(sb, indent, tp);
IThrowableProxy[] suppressed = tp.getSuppressed();
if(suppressed != null) {
for(IThrowableProxy current : suppressed) {
recursiveAppendRootCauseFirst(sb, CoreConstants.SUPPRESSED, indent + ThrowableProxyUtil.SUPPRESSED_EXCEPTION_INDENT, current);
}
}
}
示例3: buildCausalString
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
/**
* Builds an exception causation string by following the exception caused-by chain.
* @param exception The exception to process.
* @return A string describing all exceptions in the chain.
*/
private static String buildCausalString(IThrowableProxy exception)
{
final StringBuilder buff = new StringBuilder();
buff.append(exception.getClassName());
if (exception.getMessage() != null)
{
buff.append(": ").append(exception.getMessage());
}
if (exception.getCause() != null)
{
buff.append("; caused by: ").append(buildCausalString(exception.getCause()));
}
return buff.toString();
}
示例4: createThrowableData
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
/**
* fluentdサーバに転送するログデータに格納する例外情報を生成する。
*
* @param th 例外データ。
* @return 例外情報。
*/
private Map<String, Object> createThrowableData(IThrowableProxy th) {
Map<String, Object> data = new LinkedHashMap<>();
data.put("className", th.getClassName());
data.put("message", th.getMessage());
List<String> stackTrace = new ArrayList<>();
for (StackTraceElementProxy ste : th.getStackTraceElementProxyArray()) {
stackTrace.add(ste.toString());
}
data.put("stackTrace", stackTrace);
if (th.getCause() != null) {
data.put("cause", createThrowableData(th.getCause()));
}
return data;
}
示例5: toProto
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
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();
}
示例6: getException
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private IThrowableProxy getException(ILoggingEvent event) {
final IThrowableProxy throwableProxy = event.getThrowableProxy();
if (throwableProxy != null) {
final IThrowableProxy cause = throwableProxy.getCause();
if (cause != null) {
return cause;
}
}
return null;
}
示例7: render
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
public void render(StringBuilder sbuf, ILoggingEvent event) {
IThrowableProxy tp = event.getThrowableProxy();
while (tp != null) {
render(sbuf, tp);
tp = tp.getCause();
}
}
示例8: append
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
@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();
CloudwatchLogsLogEvent logEvent = new CloudwatchLogsLogEvent(event.getLevel().toString(), event.getLoggerName(), eventId, message.toString(), event.getTimeStamp(), event.getThreadName(), account, action, user, session, request);
while (!eventQueue.offer(logEvent)) {
// Discard old logging messages while queue is full.
eventQueue.poll();
discardedCount.incrementAndGet();
}
processedCount.incrementAndGet();
}
示例9: DefaultLogThrowable
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
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());
}
示例10: getRootException
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private IThrowableProxy getRootException(final IThrowableProxy throwableProxy) {
if (throwableProxy == null) {
return null;
}
IThrowableProxy rootCause = throwableProxy;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
return rootCause;
}
示例11: postProcess
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
@Override
protected void postProcess(Object eventObject, OutputStream sw) {
if (throwableExcluded)
return;
ILoggingEvent event = (ILoggingEvent) eventObject;
IThrowableProxy tp = event.getThrowableProxy();
if (tp == null)
return;
String stackTracePrefix = stackTraceLayout.doLayout(event);
boolean isRootException = true;
while (tp != null) {
StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
try {
handleThrowableFirstLine(sw, tp, stackTracePrefix, isRootException);
isRootException = false;
for (StackTraceElementProxy step : stepArray) {
StringBuilder sb = new StringBuilder();
sb.append(stackTracePrefix).append(step);
sw.write(sb.toString().getBytes());
sw.flush();
}
} catch (IOException e) {
break;
}
tp = tp.getCause();
}
}
示例12: render
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
public void render(StringBuilder sbuf, ILoggingEvent event) {
IThrowableProxy tp = event.getThrowableProxy();
sbuf.append("<tr><td class=\"Exception\" colspan=\"6\">");
while (tp != null) {
render(sbuf, tp);
tp = tp.getCause();
}
sbuf.append("</td></tr>");
}
示例13: throwableProxyToString
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
@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();
}
示例14: addExceptionsRecursively
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private void addExceptionsRecursively(final IThrowableProxy throwableProxy, final List<ExceptionVO> exceptions) {
final ExceptionVO exception = new ExceptionVO();
exception.setErrorClass(throwableProxy.getClassName());
exception.setMessage(throwableProxy.getMessage());
exception.addStackTrace(convertToStackTraces(throwableProxy));
exceptions.add(exception);
final boolean hasCause = throwableProxy.getCause() != null;
if (hasCause) {
addExceptionsRecursively(throwableProxy.getCause(), exceptions);
}
}
示例15: postProcess
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
@Override
protected void postProcess(final Object eventObject, final OutputStream sw) {
if (isThrowableExcluded()) {
return;
}
final ILoggingEvent event = (ILoggingEvent) eventObject;
IThrowableProxy tp = event.getThrowableProxy();
if (tp == null) {
return;
}
final String stackTracePrefix = stackTraceLayout.doLayout(event);
boolean isRootException = true;
while (tp != null) {
final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
try {
handleThrowableFirstLine(sw, tp, stackTracePrefix, isRootException);
isRootException = false;
for (final StackTraceElementProxy step : stepArray) {
final StringBuilder sb = new StringBuilder();
sb.append(stackTracePrefix).append(step);
sw.write(sb.toString().getBytes());
sw.flush();
}
} catch (IOException e) {
break;
}
tp = tp.getCause();
}
}