You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Following the Great Relogging activity that took place recently, a revised format for logging in Java code is established as follows:

  1. Logging.LOGGING compile-time flag has been removed. Do not use it.
  2. org.apache.log4j.Category is deprecated in favor of org.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());
  3. A class should never add "implements Logging" to its declaration statement.
  4. 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.

  • No labels