Learn R Programming

logger (version 0.4.0)

log_appender: Get or set log record appender function

Description

Get or set log record appender function

Usage

log_appender(appender = NULL, namespace = "global", index = 1)

Arguments

appender

function delivering a log record to the destination, eg appender_console(), appender_file() or appender_tee(), default NULL

namespace

logger namespace

index

index of the logger within the namespace

See Also

Other log configutation functions: log_formatter(), log_layout(), log_threshold()

Examples

Run this code
old <- logger:::namespaces_set()
## change appender to "tee" that writes to the console and a file as well
t <- tempfile()
log_appender(appender_tee(t))
log_info(42)
log_info(43)
log_info(44)
readLines(t)

## poor man's tee by stacking loggers in the namespace
t <- tempfile()
log_appender(appender_stdout)
log_appender(appender_file(t), index = 2)
log_info(42)
readLines(t)
logger:::namespaces_set(old)

Run the code above in your browser using DataLab