Following the Great Relogging activity that took place recently, a revised format for logging in Java code is established as follows:
- Logging.LOGGING compile-time flag has been removed. Do not use it.
org.apache.log4j.Category
is deprecated in favor oforg.apache.log4j.Logger
. Example:
private static final Category log = Logging.LOGGING ? Category.getInstance(POD.class.getName()) : null;
is replaced with
private static final Logger log = Logger.getLogger(POD.class.getName());
- A class should never add "implements Logging" to its declaration statement.
- The following new runtime logging level checks are available:
log.isFatalEnabled() // currently unused
log.isErrorEnabled()
log.isWarnEnabled()
log.isInfoEnabled()
log.isDebugEnabled()
log.isTraceEnabled() // currently unused
Example:
if (log.isInfoEnabled())
{
log.info("restoreRecordings: Storage not ready - deferring load of recording database");
}
For reference, here is the link to our coding guidelines. Refer to section 2.4: Logging Guidelines.