log.debug vs. logger.debug - which do you prefer?
This is probably a bit of a religious debate, but it can't hurt to ask. Do you prefer to use log.debug()
or logger.debug()
in your Java classes? A fair amount of open source projects use Commons Logging and many of them seem to use logger. Personally, I prefer log (esp. b/c it's shorter), but I'm willing to change based on what the community (particularly AppFuse users) prefer.
Here's another tip I learned today. I typically declare a log variable for each class, such as this one in BaseAction.java:
protected static Log log = LogFactory.getLog(BaseAction.class);
|
A better design can be found in Spring's DaoSupport classes. They have a logger variable that all its subclasses can use - eliminating the need to initialize a log
variable in each class.
protected final Log logger = LogFactory.getLog(getClass());
|
Obviously this is cleaner than AppFuse's current design - so I'll be changing it for 1.6. Any reasons why I shouldn't?