Declaring Logger to be static final is recommended, particularly for long lived objects such as the Struts Action class
http://www.owasp.org/index.php/Poor_Logging_Practice:_Logger_Not_Declared_Static_Final
e.g. private static final Logger LOGGER = Logger.getLogger(Donkey.class)
The Struts framework creates only one instance of an Action class for all client requests. e.g. FooAction and BarAction will only be created once.
Static means the Logger is not specific to a particular client request, but is shared by all requests.
Final means the Logger will only be instantiated once.
Logger is tread safe because it doesn't hold a state.
Monday, March 10, 2008
Subscribe to:
Post Comments (Atom)
About Me
Labels
Blog Archive
-
▼
2008
(17)
-
▼
March
(8)
- java: An algorithm for converting an array to comm...
- java: How to convert String array to Long array
- java: How to put checkboxes in DisplayTag using St...
- javascript: How to select/deselect checkboxes
- java: How to get DisplayTag sorting URL to work in...
- java: How to convert a String ArrayList into Strin...
- java: The difference between the HTML comment <!...
- java: Why Log4J's Logger should be declared static...
-
▼
March
(8)
No comments:
Post a Comment