public interface Logger
It is not usually necessary for users to create implementations of this interface, as
the LoggerProvider
interface contains several predefined instances which provide the most commonly required Logger
implementations.
By default, logging is configured automatically according to the algorithm described in the static Config.LoggerProvider
property.
An instance of a class that implements this interface is used by calling the Source.setLogger(Logger)
method on the relevant Source
object.
Four logging levels are defined in this interface. The logging level is specified only by the use of different method names, there is no class or type defining the levels. This makes the code required to wrap other logging frameworks much simpler and more efficient.
The four logging levels are:
IMPLEMENTATION NOTE: Ideally the java.util.logging.Logger
class could have been used as a basis for logging, even if used to define a wrapper
around other logging frameworks.
This would have avoided the need to define yet another logging interface, but because java.util.logging.Logger
is implemented very poorly,
it is quite tricky to extend it as a wrapper.
Other logging wrapper frameworks such as SLF4J or
Jakarta Commons Logging provide good logging interfaces, but to avoid
introducing dependencies it was decided to create this new interface.
Config.LoggerProvider
Modifier and Type | Method and Description |
---|---|
void |
debug(java.lang.String message)
Logs a message at the DEBUG level.
|
void |
error(java.lang.String message)
Logs a message at the ERROR level.
|
void |
info(java.lang.String message)
Logs a message at the INFO level.
|
boolean |
isDebugEnabled()
Indicates whether logging is enabled at the DEBUG level.
|
boolean |
isErrorEnabled()
Indicates whether logging is enabled at the ERROR level.
|
boolean |
isInfoEnabled()
Indicates whether logging is enabled at the INFO level.
|
boolean |
isWarnEnabled()
Indicates whether logging is enabled at the WARN level.
|
void |
warn(java.lang.String message)
Logs a message at the WARN level.
|
void error(java.lang.String message)
message
- the message to log.void warn(java.lang.String message)
message
- the message to log.void info(java.lang.String message)
message
- the message to log.void debug(java.lang.String message)
message
- the message to log.boolean isErrorEnabled()
true
if logging is enabled at the ERROR level, otherwise false
.boolean isWarnEnabled()
true
if logging is enabled at the WARN level, otherwise false
.boolean isInfoEnabled()
true
if logging is enabled at the INFO level, otherwise false
.boolean isDebugEnabled()
true
if logging is enabled at the DEBUG level, otherwise false
.