how to use log4j with multiple classes?

后端 未结 5 1931
无人及你
无人及你 2020-12-14 18:06

I\'m currently writing a big project in java, with numerous classes, some classes are quiet small, that simply represent objects with only few methods. I have a logger set i

5条回答
  •  鱼传尺愫
    2020-12-14 18:33

    Your logger instances should typically be private, static and final. By doing so, each class will have it's own logger instance (that is created once the class is loaded), so that you could identify the class where the log record was created, and also you no longer need to pass logger instances across classes.

提交回复
热议问题