JSLogger
Overview
The JSLogger
class provides a comprehensive API for managing logging operations. It supports constructing log events with various severity levels, such as fatal, error, warn, info, debug, and trace, using the JSLogBuilder
instances it creates. Logs can include messages formatted with arguments, enabling flexible and detailed logging. The class offers methods to check if a specific logging level is enabled, allowing efficient logging decisions. It also allows dynamically setting the logger's logging level, overriding the default configuration. This global change persists until the application server is restarted. The current logging level can be retrieved as a string using the level
property.
Properties Summarized
Methods Summarized
Properties Detailed
always
Construct a log event that will always be logged.
Type JSLogBuilder a LogBuilder
Sample
debug
Construct a debug log event.
Type JSLogBuilder a LogBuilder
Sample
debugEnabled
Check if the current logger's logging level enables logging on the debug level. Return true if the logger's level is set to debug or trace.
Type Boolean true if 'debug' level is enabled for logging
error
Construct an error log event.
Type JSLogBuilder a LogBuilder
Sample
errorEnabled
Check if the current logger's logging level enables logging on the error level. Return true if the logger's level is set to error, warn, info, debug or trace.
Type Boolean true if 'error' level is enabled for logging
fatal
Construct a fatal log event.
Type JSLogBuilder a LogBuilder
Sample
fatalEnabled
Check if the current logger's logging level enables logging on the fatal level. Return true if the logger's level is set to fatal, error, warn, info, debug or trace.
Type Boolean true if 'fatal' level is enabled for logging
info
Construct an info log event.
Type JSLogBuilder a LogBuilder
Sample
infoEnabled
Check if the current logger's logging level enables logging on the info level. Return true if the logger's level is set to info, debug or trace.
Type Boolean true if 'info' level is enabled for logging
level
Get the logging level of this logger
Type String the logging level of this logger
trace
Construct a trace log event.
Type JSLogBuilder a LogBuilder
Sample
traceEnabled
Check if the current logger's logging level enables logging on the trace level. Return true if the logger's level is set to trace.
Type Boolean true if 'trace' level is enabled for logging
warn
Construct a warn log event.
Type JSLogBuilder a LogBuilder
Sample
warnEnabled
Check if the current logger's logging level enables logging on the warn level. Return true if the logger's level is set to warn, info, debug or trace.
Type Boolean true if 'warn' level is enabled for logging
Methods Detailed
setLevel(level)
Set the level for this logger. Be aware that this will override the logging level as configured in log4j.xml, meaning it affects all JSLogger instances based on that configuration. This changes the global configuration, meaning that restarting the client will not reset the logging level to it's default state. Only restarting the application server will reset the logging level to it's default state.
Parameters
JSLogBuilder level the desired logging level for this logger
Returns: void
Sample
Last updated
Was this helpful?