R: Appenders

appenders {log4r} | R Documentation

## Appenders

### Description

In log4j etymology, Appenders are destinations where messages are written. Depending on the nature of the destination, the format of the messages may be controlled using a Layout.

The most basic appenders log messages to the console or to a file; these are described below.

For implementing your own appenders, see Details.

### Usage

    console_appender(layout = default_log_layout())

    file_appender(file, append = TRUE, layout = default_log_layout())

### Arguments

`layout` | A layout function taking a `level` parameter and additional arguments corresponding to the message. See `layouts`.
`file` | The file to write messages to.
`append` | When `TRUE`, the file is not truncated when opening for the first time.

### Details

Appenders are implemented as functions with the interface `function(level, ...)`. These functions are expected to write their arguments to a destination and return `invisible(NULL)`.

### See Also

`tcp_appender`, `http_appender`, `syslog_appender`

### Examples

    # The behaviour of an appender can be seen by using them directly; the
    # following snippet will write the message to the console.
    appender <- console_appender()
    appender("INFO", "Input has length ", 0, ".")

[Package log4r version 0.4.2 Index]