Logger Plugin is responsible for collecting logs from server plugins and PHP application workers'
displaying them in the RoadRunner
STDOUT. It comes with a variety of options that allow you to customize the
way your application logs are collected and displayed.
There are three available modes:
production - This mode uses logger settings that are optimized for production usage.
development - This mode is enabled by default and is designed for use during application development. In
development mode, DPanicLevel logs panic, console colors are used, and logs are written to standard error. Sampling
is disabled, and stack traces are automatically included on logs of WarnLevel and above.
raw - This mode displays messages as raw output without any formatting. This mode is useful in production
environments where you need to parse logs programmatically.
productionmode in production environments. It is optimized for production usage.
Logger supports two types of encoding,
json. By default,
console encoding is used, which outputs logs
in a friendly format. JSON encoding, on the other hand, returns messages in a JSON Structured logging format. This
format presents log messages as JSON objects with key-value pairs representing each log message field, making them more
machine-readable and easier to process programmatically. JSON encoding is also better suited for production usage.
The level is used to specify the logging level. This means that only log messages with a severity level will be sent to
this channel. Available levels include
The default level is
By default, RoadRunner sends logs to
STDERR. However, you can configure RoadRunner to send logs to
STDOUT by using
the output key.
It allows configuring custom line endings for the logger. By default, the plugin uses
\n as the line ending. Note that the
\n is a forced default. This means that if the value is empty, RoadRunner will still use
\n. So no empty line endings are allowed.
In addition, you can configure each plugin log messages individually using the
channels section. It allows you to
customize the logger settings for each plugin independently. You can disable logging for a particular plugin or change
its log mode and output destination.
encoding: console # default value
mode: none # disable server logging. Also `off` can be used.
It is possible to redirect channels or the entire log output to a file. To use the file logger, you need to set
file_logger_options.log_output option to the filename where you want to write the logs.
You can also redirect a specific channel to a file. To do this, you need to specify the channel name in the
log_output: Filename is the file to write logs to in the same directory. It uses
os.TempDir() if empty.
max_size: is the maximum size in megabytes of the log file before it gets rotated. It defaults to 100 megabytes.
max_age: is the maximum number of days to retain old log files based on the timestamp encoded in their filename.
Note that a day is defined as 24 hours and may not exactly correspond to calendar days due to daylight savings, leap
seconds, etc. The default is not to remove old log files based on age.
max_backups: is the maximum number of old log files to retain. The default is to retain all old log files (though
MaxAge may still cause them to get deleted.)
compress: determines if the rotated log files should be compressed using gzip. The default is not to perform
log_ending: line ending to use in the logger. Default is new line -
Feel free to register your own ZapLogger extensions.