fix (接口自动化): 修复执行控制台异常日志不输出问题

This commit is contained in:
fit2-zhao 2021-08-18 18:30:48 +08:00 committed by fit2-zhao
parent 3ff5f03f90
commit 0080615344
1 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.api.jmeter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.LogUtil;
@ -23,6 +24,16 @@ public class JmeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEve
.append(event.getLevel()).append(" ")
.append(event.getThreadName()).append(" ")
.append(event.getFormattedMessage()).append("\n");
if (event.getThrowableProxy() != null) {
message.append(event.getThrowableProxy().getMessage()).append("\n");
message.append(event.getThrowableProxy().getClassName()).append("\n");
if (event.getThrowableProxy().getStackTraceElementProxyArray() != null) {
for (StackTraceElementProxy stackTraceElementProxy : event.getThrowableProxy().getStackTraceElementProxyArray()) {
message.append(" ").append(stackTraceElementProxy.getSTEAsString()).append("\n");
}
}
}
if (logger.containsKey(event.getTimeStamp())) {
logger.get(event.getTimeStamp()).append(message);
} else {