Issue#6377 changed slf4j LoggingEvent to apache log4j LoggingEvent (#6378)

Co-authored-by: Margaux Cabrera <margaux.cabrera@skulibrary.com>
Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
This commit is contained in:
margauxcabrera 2021-02-16 20:24:57 +11:00 committed by GitHub
parent 544bdbec5b
commit cd920e274f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -9,8 +9,8 @@ Release Notes.
#### Java Agent
* Remove invalid mysql configuration in agent.config.
* Add net.bytebuddy.agent.builder.AgentBuilder.RedefinitionStrategy.Listener to show detail message when redefine errors occur
* Add net.bytebuddy.agent.builder.AgentBuilder.RedefinitionStrategy.Listener to show detail message when redefine errors occur.
* Fix ClassCastException of log4j gRPC reporter.
#### OAP-Backend
* Allow user-defined `JAVA_OPTS` in the startup script.

View File

@ -36,7 +36,7 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<scope>test</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>

View File

@ -35,7 +35,7 @@ import org.apache.skywalking.apm.network.logging.v3.LogDataBody;
import org.apache.skywalking.apm.network.logging.v3.LogTags;
import org.apache.skywalking.apm.network.logging.v3.TextLog;
import org.apache.skywalking.apm.network.logging.v3.TraceContext;
import org.slf4j.event.LoggingEvent;
import org.apache.log4j.spi.LoggingEvent;
public class GRPCLogAppenderInterceptor implements InstanceMethodsAroundInterceptor {
@ -103,6 +103,8 @@ public class GRPCLogAppenderInterceptor implements InstanceMethodsAroundIntercep
}
private String transformLogText(final LoggingEvent event) {
return event.getMessage() + "\n" + ThrowableTransformer.INSTANCE.convert2String(event.getThrowable(), 2048);
final String throwableString = Objects.isNull(event.getThrowableInformation()) ? "" :
ThrowableTransformer.INSTANCE.convert2String(event.getThrowableInformation().getThrowable(), 2048);
return event.getMessage() + "\n" + throwableString;
}
}