| AppenderSyslog | R Documentation |
An Appender that writes to the syslog on supported POSIX platforms. Requires the rsyslog package.
The $new() method returns an R6::R6 that inherits from
lgr::Appender and can be uses as an appender by a lgr::Logger.
lgr::Filterable -> lgr::Appender -> AppenderSyslog
syslog_levels.Either a named character vector or a function
mapping lgr lgr::log_levels to rsyslog log levels. See
$set_syslog_levels().
identifiercharacter scalar. A string identifying the process;
if NULL defaults to the logger name
syslog_levels.Either a named character vector or a function
mapping lgr lgr::log_levels to rsyslog log levels. See
$set_syslog_levels().
new()AppenderSyslog$new(
identifier = NULL,
threshold = NA_integer_,
layout = LayoutFormat$new("%m"),
filters = NULL,
syslog_levels = c(CRITICAL = "fatal", ERR = "error", WARNING = "warn", INFO = "info",
DEBUG = "debug", DEBUG = "trace")
)append()AppenderSyslog$append(event)
set_syslog_levels()Define conversion between lgr and syslog log levels
AppenderSyslog$set_syslog_levels(x)
x a named character vector mapping whose names are log
levels as understood by rsyslog::syslog() and whose values are lgr log levels (either character or numeric)
a function that takes a vector of lgr log levels as input and
returns a character vector of log levels for rsyslog::syslog().
set_identifier()Set a string to identify the process.
AppenderSyslog$set_identifier(x)
lgr::LayoutFormat, lgr::LayoutGlue
Other Appenders:
AppenderAWSCloudWatchLog,
AppenderDbi,
AppenderDynatrace,
AppenderElasticSearch,
AppenderGmail,
AppenderPool,
AppenderPushbullet,
AppenderSendmail
if (requireNamespace("rsyslog", quietly = TRUE) && Sys.info()[["sysname"]] == "Linux") {
lg <- lgr::get_logger("rsyslog/test")
lg$add_appender(AppenderSyslog$new(), "syslog")
lg$info("A test message")
print(system("journalctl -t 'rsyslog/test'"))
invisible(lg$config(NULL)) # cleanup
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.