Why calling LoggerFactory.getLogger(…) every time is not recommended?

前端 未结 11 2239
借酒劲吻你
借酒劲吻你 2020-12-24 01:07

I\'ve read tons of posts and documents (on this site and elsewhere) pointing that the recommended pattern for SFL4J logging is:

public class MyClass {
    fi         


        
11条回答
  •  甜味超标
    2020-12-24 01:22

    I may have missed it in one of the earlier comments, but i didn't see a mention that the logger is static, the call to LoggerFactory is made ONCE (per instantiation of the class) - so the initial concern about multiple calls to create the logger is just wrong.

    The other comments regarding all the issues with adding wrapping classes are very important as well.

提交回复
热议问题