ppkarwasz commented on issue #4697:
URL: https://github.com/apache/eventmesh/issues/4697#issuecomment-1872905471

   > @ppkarwasz When rewriting the supplier usage of Log4j2 to Slf4j using 
rewrite-logging-frameworks, how would the following code be modified?
   > 
   > ```
   >         try {
   >             ......
   >         } catch (Exception e) {
   >             log.debug("A time-consuming method: {}", () -> myMethod(), () 
-> e);
   >         }
   > ```
   
   Currently `rewrite-logging-frameworks` doesn't rewrite lambdas (it leaves 
them as is), but it might in the future, when 
openrewrite/rewrite-logging-frameworks#127 has been implemented.
   
   > Con: If one day we no longer use Log4j2, there may be a need to switch to 
a different logging artifact.
   
   This is a common misconception about Log4j 2.x: Log4j API and Log4j Core 
(both developed by the Apache Logging Services team) are separate products (cf. 
[API separation](https://logging.apache.org/log4j/2.x/manual/api-separation)) 
the same way SLF4J and Logback (both developed by Ceki Gülcü) are separate 
products.
   
   If you were using the Log4j API, you can:
   
   - switch to Logback by replacing `log4j-core` with `log4j-to-slf4j` + 
`logback-classic` as **runtime** dependencies,
   - switch to `java.util.logging` by replacing `log4j-core` with 
`log4j-to-jul`.
   
   These changes do not require changes in the code.
   
   Regarding the advantages of the Log4j API, Remko wrote a [nice StackOverflow 
answer](https://stackoverflow.com/a/41500347/11748454) some time ago.


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