Skip to contents

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.

Usage

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_switch(..., default = logger_null())

common_log_format

combined_log_format

Arguments

api

A plumber2 api object to set the logger on

logger

A logger function. If NULL then the current logger is kept

access_log_format

A glue string giving the format for the access logs. plumber2 (through fiery) provides the predefined common_log_format and combined_log_format, but you can easily create your own. See fiery::loggers for which variables the glue string has access to.

format

A glue string specifying the format of the log entry

file

A file or connection to write to

default_level

The log level to use for events that are not request, websocket, message, warning, or error

...

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. logger_switch(error =, warning = logger_file('errors.log')).

default

A catch-all logger for use with events not defined in ...