BFergerson edited a comment on issue #5863:
URL: https://github.com/apache/skywalking/issues/5863#issuecomment-730400383


   @vcjmhg, 
   
   > > I was unaware of the format `AbstractSpan.error()` was already using
   > 
   > @BFergerson, The result of the previous discussion is that we don’t care 
about the format `AbstractSpan.error()` was already using, we will provide a 
configuration file to control the format of the log.
   > 
   > ```yaml
   >   - name: "log4j2"
   >     packages:
   >       - package1
   >       - package2
   >     level: "trace"
   >     pattern: "%date %level [%thread] %logger{10} [%file:%line] %msg%n"
   >     expression: "Regular expression"
   > ```
   > 
   > In the above config file, `pattern` will control the format of logging 
information that we need.
   
   I don't think the `pattern` from your configuration and the format which 
`AbstractSpan.error(Throwable)` is using are mutually exclusive. `pattern` 
would simply take the place of `message`. I'm probably just increasing 
confusion by using the word format so liberally. Basically, I'm thinking this:
   ```java
   val pattern = null //todo: parse and format log message based on the 
configured pattern from logfilter.yaml
   val level = null //todo: determine log level being logged
   
   if (ContextManager.isActive()) {
       Map<String, String> logMap = new HashMap<>();
       logMap.put("event", level);
       logMap.put("message", pattern);
       if (level == "error") {
           logMap.put("error.kind", null); //todo: determine error kind
           logMap.put("stack", null); //todo: determine stack trace
       }
   
       ContextManager.activeSpan().log(System.currentTimeMillis(), logMap);
   }
   ```
   
   Though again, my only question would be whether or not the stack trace was 
always included regardless of log level.


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to