Search code examples
javaloggingstaticfinal

Should be logger always final and static?


Class can be accessed from many threads. Must be logger in this case also be final and static? Thanks.


Solution

  • All major java logging packages (java.util.logging, log4j, etc.) are synchronized and thread safe. The standard pattern of a private final static logger per class is fine even if the class is called from multiple threads.