Learn R Programming

futile.logger (version 1.0.0)

configLogger: Create and manage loggers within 'futile.logger'

Description

A number of pre-defined loggers are provided within 'futile.logger'. The logger configurations illustrate basic usage in addition to more advanced features such as logger inheritance, multiple appenders for a logger, and appender threshold overrides.

Usage

configLogger(type, ..., threshold = INFO, defaultLayout = simpleLayout)

Arguments

type
The type of logger to configure
threshold
The logger threshold
defaultLayout
The default layout used in the appenders
...
Additional arguments to specific configurations

Value

  • Nothing is returned, although the logging system is configured properly. To see the results, run loggerAppender(name) to view the appenders for the logger and loggerThreshold(name) to view the logger threshold.

Details

This function is the entry point for configuring 'futile.logger' with built-in configurations. The available types and associated arguments are described below. All configurations described below use INFO as the default log level and simpleLayout as the default layout. These can be overridden by passing the appropriate argument to 'configLogger'.

'console' Writes all log messages to the console. Useful for interactive development

'file' file - The path to the log file Writes all log messages to the specified file

'error' err.file - The path to the error file Writes all log messages to the console while messages at WARN or worse are also written to an error file

c('console','file') file - The path to the log file Writes all log messages to a file with messages at WARN or worse or also routed to the console

c('error','file') log.file - The path to the normal log file err.file - The path to the error file Writes messages to a general log file and to the console for messages at WARN or worse. A secondary error logger will log error messages at WARN or worse.

Once a configuration is called, it is necessary to reset the logger options prior to using a different configuration. This is done by calling the 'futile.options' function reset.options(logger.options).

Examples

Run this code
reset.options(logger.options)
  configLogger('console')
  lg <- getLogger()
  lg(DEBUG, "This won't print")
  lg(WARN, "But this will")

Run the code above in your browser using DataLab