dcsimg
 

Submitted by: Octavia Anghel(octaviaanghel@gmail.com)

Wednesday Apr 18th 2018 by Octavia Anghel

Language: Java, Level: Beginner: - See why it is a good idea to store the log instance in a static final variable.

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
Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved