| api_logger | R Documentation |
plumber2 has a build-in logging facility that takes care of logging any
conditions that are caught, as well as access logs. Further it is possible to
log custom messages using the log() method on the api object. However, the
actual logging is handled by a customizable function that can be set. You can
read more about the logging infrastructure in the
fiery documentation. plumber2 reexports the loggers
provided by fiery so they are immediately available to the user.
api_logger(api, logger = NULL, access_log_format = NULL)
logger_null()
logger_console(format = "{time} - {event}: {message}")
logger_file(file, format = "{time} - {event}: {message}")
logger_logger(default_level = "INFO")
logger_otel(format = "{message}")
logger_switch(..., default = logger_null())
common_log_format
combined_log_format
api |
A plumber2 api object to set the logger on |
logger |
A logger function. If |
access_log_format |
A glue string giving the format for the access logs.
plumber2 (through fiery) provides the predefined |
format |
A glue-like string specifying the format of the
log entry. Only the variables |
file |
A file or connection to write to |
default_level |
The log level to use for events that are not |
... |
A named list of loggers to use for different events. The same
semantics as switch is used so it is possible to let events
fall through e.g. |
default |
A catch-all logger for use with events not defined in |
Logger setup doesn't have a dedicated annotation tag, but you can set it up
in a @plumber block
#* @plumber
function(api) {
api |>
api_logger(logger = logger_null())
}
# Use a different access log format
api() |>
api_logger(access_log_format = combined_log_format)
# Turn off logging
api() |>
api_logger(logger_null())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.