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.
logs: mode: production
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.
logs: encoding: console
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
logs: level: info
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.
logs: output: stdout
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.
logs: line_ending: "\r\n"
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.
version: "3" logs: encoding: console # default value level: info channels: server.mode: none # disable server logging. Also `off` can be used. http: mode: production output: http.log
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.
logs: mode: development file_logger_options: log_output: "test.log" max_size: 10 max_age: 24 max_backups: 10 compress: true
You can also redirect a specific channel to a file. To do this, you need to specify the channel name in the
logs: mode: development level: debug channels: http: file_logger_options: log_output: "test.log" max_size: 10 max_age: 24 max_backups: 10 compress: true
log_output: Filename is the file to write logs to in the same directory. It uses
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 compression.
log_ending: line ending to use in the logger. Default is new line -
Feel free to register your own ZapLogger extensions.