| Interface | Description |
|---|---|
| Log |
A log instance has a name and supplies means to write log messages with priority level.
|
| LogContext |
Logger context stores diagnostic context data to current thread.
|
| LogProvider |
Log service provider interface.
|
| Class | Description |
|---|---|
| AbstractLog |
Basic implementation of logger interface.
|
| DefaultLog |
Default logger used when logger implementation is missing.
|
| DefaultLogContext |
Default log context does nothing.
|
| DefaultLogProvider |
Default log provider creates
DefaultLog instances. |
| LogFactory |
Logging system facade.
|
| Enum | Description |
|---|---|
| LogLevel |
Logging level, also known as priority.
|
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()");
...
}
}
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.Copyright © 2018. All rights reserved.