Create a logger
createLogger(
name = "SIMPLE",
threshold = "INFO",
appenders = list(createConsoleAppender())
)
A name for the logger.
The threshold to be used for reporting.
A list of one or more appenders as created for example using the
createConsoleAppender
or createFileAppender
function.
An object of type Logger
, to be used with the registerLogger
function.
Creates a logger that will log messages to its appenders. The logger will only log messages at a level equal to or higher than its threshold. For example, if the threshold is "INFO" then messages marked "INFO" will be logged, but messages marked "TRACE" will not. The order of levels is "TRACE", "DEBUG", "INFO", "WARN", "ERROR, "and FATAL".
appender <- createConsoleAppender(layout = layoutTimestamp)
logger <- createLogger(name = "SIMPLE",
threshold = "INFO",
appenders = list(appender))
registerLogger(logger)
logTrace("This event is below the threshold (INFO)")
logInfo("Hello world")
#> 2024-08-23 08:25:54 Hello world
#> 2024-08-23 08:25:54 Hello world
unregisterLogger("SIMPLE")
#> [1] TRUE