Class ExtensionsLogger
java.lang.Object
net.sf.basedb.util.extensions.logging.ExtensionsLogger
public class ExtensionsLogger extends Object
A simple logger that services can use to send log message to the BASE
core. An instance is handed out to the service by the
ServiceControllerAction.start()
method, which the service
can use as long as it is running.
Note that the BASE core will automatically send INFO-level messages when the service is started and stopped.
The log is kept in memory only and will not survive server restarts. The number of log entries is also limited. When the limit is reached the oldest entries are automatically removed from the log.
- Since:
- 3.19.8
- Author:
- nicklas
-
Field Summary
Fields Modifier and Type Field Description private ExtensionsLog
log
private org.slf4j.Logger
otherLogger
-
Constructor Summary
Constructors Constructor Description ExtensionsLogger(ExtensionsLog log)
ExtensionsLogger(ExtensionsLog log, org.slf4j.Logger otherLogger)
-
Method Summary
Modifier and Type Method Description void
debug(String msg)
Log a DEBUG message.void
debug(String msg, Throwable t)
Log a DEBUG message with an optional stacktrace.void
error(String msg)
Log an ERROR message.void
error(String msg, Throwable t)
Log an ERROR message with an optional stacktrace.void
info(String msg)
Log an INFO message.void
info(String msg, Throwable stacktrace)
Log an INFO message with an optional stacktrace.boolean
isDebugEnabled()
Check if DEBUG logging has been enabled or not.boolean
isTraceEnabled()
Check if TRACE logging has been enabled or not.void
log(LogLevel level, String msg)
Log a message at the specified level.void
log(LogLevel level, String msg, Throwable stacktrace)
Log a message at the specified level with an optional stacktrace.void
trace(String msg)
Log a TRACE message with the related SLF4J logger.void
trace(String msg, Throwable t)
Log a TRACE message with an optional stacktrace.void
warn(String msg)
Log a WARNING message.void
warn(String msg, Throwable t)
Log a WARNING message with an optional stacktrace.ExtensionsLogger
wrap(org.slf4j.Logger otherLogger)
Wrap a generic SLF4J logger with this logger.
-
Field Details
-
log
-
otherLogger
private final org.slf4j.Logger otherLogger
-
-
Constructor Details
-
ExtensionsLogger
ExtensionsLogger(ExtensionsLog log) -
ExtensionsLogger
ExtensionsLogger(ExtensionsLog log, org.slf4j.Logger otherLogger)
-
-
Method Details
-
wrap
Wrap a generic SLF4J logger with this logger. Messages that are submitted to the logger created by this method are also forwarded to the SLF4J logger. -
isDebugEnabled
public boolean isDebugEnabled()Check if DEBUG logging has been enabled or not. Debug logging can be enabled either by theExtensionsLog.setDebugEnabled(boolean)
method or by a wrappedLogger
. -
isTraceEnabled
public boolean isTraceEnabled()Check if TRACE logging has been enabled or not. Trace logging is enabled only if both DEBUG logging andExtensionsLog.isCopyingToStdout()
are enabled or if a wrappedLogger
has it enabled. -
log
Log a message at the specified level. -
log
Log a message at the specified level with an optional stacktrace. -
info
Log an INFO message. -
info
Log an INFO message with an optional stacktrace. -
warn
Log a WARNING message. -
warn
Log a WARNING message with an optional stacktrace. -
error
Log an ERROR message. -
error
Log an ERROR message with an optional stacktrace. -
debug
Log a DEBUG message. -
debug
Log a DEBUG message with an optional stacktrace. -
trace
Log a TRACE message with the related SLF4J logger. If no SLF4J logger is related (seewrap(org.slf4j.Logger)
) all TRACE messages will be ignored. -
trace
Log a TRACE message with an optional stacktrace. If no SLF4J logger is related (seewrap(org.slf4j.Logger)
) all TRACE messages will be ignored.
-