evanxuhe opened a new issue #2938: Log4j2 Aysnc Log Support. No trace Id when 
using async of Log4j2
URL: https://github.com/apache/skywalking/issues/2938
 
 
   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   I found that there is  No trace Id when using async of Log4j2
   Is there any plan to support this?
   
   I find that the TraceContext is Thread Local. And **when use async log 
thread, PrintTraceIdInterceptor can't get traceId from ThreadLocal 
TraceContext**
   ```
   public class PrintTraceIdInterceptor implements 
StaticMethodsAroundInterceptor {
       /**
        * Override 
org.apache.skywalking.apm.toolkit.log.log4j.v2.x.Log4j2OutputAppender.append(),
        *
        * @param method
        * @param result change this result, to output the traceId. The origin 
append() method will not invoke.
        */
       @Override public void beforeMethod(Class clazz, Method method, Object[] 
allArguments, Class<?>[] parameterTypes,
           MethodInterceptResult result) {
           ((StringBuilder)allArguments[0]).append("TID:" + 
ContextManager.getGlobalTraceId());
   
           //make sure origin method do not invoke.
           result.defineReturnValue(null);
       }
   
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to