April 18, 2018

Should Log Instances Be Static or Not?

Private static final Log log = LogFactory.getLog(MyClass.class); It is a good idea to store the log instance in a static final variable, because: No problems with serializable classes Initialization cost only once: getLog() may not be as cheap as you might think Automatically thread-safe, only if the final keyword is