Skip navigation links

Package js.log

Logging system.

See: Description

Package js.log Description

Logging system. This package contains both service providers interface and client API. At a minimum service provider should implement LogProvider and AbstractLog.

Client usage is classic: uses LogFactory to get named logger instance the operates on it.

 public class Sample {
        private static final Log log = LogFactory.getLog(Sample.class);
        ...
        public void method() {
                log.trace("method()");
                ...
        }
 }
 

Formatted Log

Is not uncommon to need adding variables to log records and often it is solved using string concatenation. The problem with string concatenation is it is performed even if log level is disabled. Solution to this problem is to wrap into log level enabled check resulting in more verbose code.
        if(log.isEnabledFor(Level.DEBUG)) {
                log.debug("Class loaded " + class.getName());
        }
 
instead of
        log.debug("Class loaded %s.", class.getName());
 
The second solution executes string formatting only if log level is enabled but check for level is performed into logger writer.
Version:
final
Author:
Iulian Rotaru
Skip navigation links

Copyright © 2018. All rights reserved.