Pil0tXia opened a new issue, #4697:
URL: https://github.com/apache/eventmesh/issues/4697

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Enhancement Request
   
   This issue is a sub-task of https://github.com/apache/eventmesh/issues/4681.
   
   The purpose of this issue is to provide syntactic support for resolving the 
logging problem #4681 by upgrading the versions of log4j and slf4j.
   
   ## Background Knowledge
   
   Disscussion: https://github.com/apache/logging-log4j2/discussions/2133
   
   The additional `isDebugEnabled()` check before `log.debug()` is performed in 
order to avoid invoking the methods referenced in the `message` field, thus 
improving logging performance. For example:
   
   ```java
   log.debug("formatted msg: {}", formatMsg(rawMsg));
   ```
   
   Even when the log level is set to `info`, the `formatMsg(rawMsg)` method 
will still be called and return a result before being passed as an argument to 
`log.debug()`. This takes time.
   
   
   ### Describe the solution you'd like
   
   ## Solution Selection
   
   Since slf4j does not support passing arguments through the Supplier 
introduced in log4j 2.13.0 (discussed in 
https://github.com/qos-ch/slf4j/pull/70, no need to read though), we will not 
adopt the solution of lazy invocation by passing the Supplier parameter. 
Additionally, the usage of the Supplier appears redundant, and most 
contributors cannot understand the difference between using a Supplier or not 
without prior knowledge.
   
   The [Fluent Logging API](https://www.slf4j.org/manual.html#fluent) since 
slf4j 2.0.0 provides a more elegant and space-saving way of writing code. The 
modifications to the `WatchFileManager` class demonstrate the recommended 
approach.
   
   
![image](https://github.com/apache/eventmesh/assets/41445332/582dccc7-bd08-4980-aa9e-9ad7edfd4fea)
   
   ## Scenarios where Fluent Logging API is unnecessary
   
   Only the scenario mentioned in the Background Knowledge section require the 
use of Fluent Logging API. For example, in the case of the changes in `Codec` 
class L224, where no object parameters are passed or existing objects are 
referenced, there is no additional performance overhead, and there is no need 
to pre-evaluate log levels. The simplest usage of slf4j can be directly applied.
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct) *


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to