Create a logger

createLogger(
  name = "SIMPLE",
  threshold = "INFO",
  appenders = list(createConsoleAppender())
)

Arguments

name

A name for the logger.

threshold

The threshold to be used for reporting.

appenders

A list of one or more appenders as created for example using the createConsoleAppender or createFileAppender function.

Value

An object of type Logger, to be used with the registerLogger function.

Details

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".

Examples

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