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 included
- Usable from static and non-static code