aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes why we use logger instance as a static in java(Priorty urgent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "why we use logger instance as a static in java(Priorty urgent)" Watch "why we use logger instance as a static in java(Priorty urgent)" New topic
Author

why we use logger instance as a static in java(Priorty urgent)

Ashutosh kumar singh
Greenhorn

Joined: Feb 27, 2008
Posts: 26
Why i use logger instance is static in java file. We can use without static also
then what is the reason. Can any body give me brief idea.

ex.

static Logger logger = Logger.getLogger(ABC.class);


thanks
Ashutosh kumar Singh
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30776
    
157

Ashutosh,
If it is static, there is only one copy for all instances of the class. This means "Logger.getLogger(ABC.class);" is executed less times. If it is doing something resource intensive like reading a file or using reflection, this saves time and makes your program faster.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: why we use logger instance as a static in java(Priorty urgent)