dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Beginner
Apr 18, 2018

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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 included
  • Usable from static and non-static code
Octavia Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date