This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Poor Logging Practice"
(→Description) |
|||
Line 23: | Line 23: | ||
</pre> | </pre> | ||
+ | ===Poor Logging Practice: Multiple Loggers=== | ||
+ | It is a poor logging practice to use multiple loggers rather than logging levels in a single class. | ||
+ | Good logging practice dictates the use of a single logger that supports different logging levels for each class. | ||
+ | The following code errantly declares multiple loggers. | ||
+ | |||
+ | <pre> | ||
+ | public class MyClass { | ||
+ | private final static Logger good = | ||
+ | Logger.getLogger(MyClass.class); | ||
+ | private final static Logger bad = | ||
+ | Logger.getLogger(MyClass.class); | ||
+ | private final static Logger ugly = | ||
+ | Logger.getLogger(MyClass.class); | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | </pre> | ||
==Risk Factors== | ==Risk Factors== |
Revision as of 00:08, 18 February 2009
This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.
Last revision (mm/dd/yy): 02/18/2009
Description
Logger Not Declared Static Final
Loggers should be declared to be static and final.
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.
The following statement errantly declares a non-static logger.
private final Logger logger = Logger.getLogger(MyClass.class);
Poor Logging Practice: Multiple Loggers
It is a poor logging practice to use multiple loggers rather than logging levels in a single class.
Good logging practice dictates the use of a single logger that supports different logging levels for each class.
The following code errantly declares multiple loggers.
public class MyClass { private final static Logger good = Logger.getLogger(MyClass.class); private final static Logger bad = Logger.getLogger(MyClass.class); private final static Logger ugly = Logger.getLogger(MyClass.class); ... }
Risk Factors
TBD
Examples
Related Attacks
Related Vulnerabilities
Related Controls
Related Technical Impacts
References
Note: A reference to related CWE or CAPEC article should be added when exists. Eg: