Search:     Advanced search
server monitoring

Poor Logging Practice: Logger Not Declared Static Final

Article ID: 116
Last updated: 06 May, 2008
Views: 303
Posted: 06 May, 2008
by: Tech Pubs S.
Updated: 06 May, 2008
by: Tech Pubs S.

Poor Logging Practice: Logger Not Declared Static Final

Abstract

Loggers should be declared to be static and final.

Description

It is good programming practice to share a single logger object between all of the instances of a particular class and to use the same logger for the duration of the program.

Examples

The following statement errantly declares a non-static logger.

	private final Logger logger =     
Logger.getLogger(MyClass.class);
This article was:   Helpful | Not Helpful
Prev   Next
Poor Logging Practice: Multiple Loggers     Null Dereference