ABSTRACT

Declare loggers to be static and final.

EXPLANATION

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.

Example 1: The following statement errantly declares a non-static logger.


private final Logger logger =
Logger.getLogger(MyClass.class);

REFERENCES

[1] Standards Mapping - FIPS200 - (FISMA) AU

[2] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 398