RoadRunner provides the ability to control the log for each plugin individually.
To configure logging globally use
logs config section:
logs: mode: production output: stderr
To use develop mode. It enables development mode (which makes DPanicLevel logs panic), uses a console encoder, writes to standard error, and disables sampling. Stacktraces are automatically included on logs of WarnLevel and above.
logs: mode: development output: stderr
To output to separate file:
logs: mode: production output: stderr file_logger_options: log_output: "/tmp/my.log" max_size: 100 max_age: 1 max_backups : 5 compress: false
To use console friendly output:
logs: encoding: console # default value
To suppress messages under specific log level:
logs: encoding: console # default value level: info
It is possibe to redirect channels or whole log output to the file:
Config sample with file logger:
logs: mode: development level: debug file_logger_options: log_output: "test.log" max_size: 10 max_age: 24 max_backups: 10 compress: true
OR for the log channel:
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
Starting from the
v2.5.0 RR allows configuring custom line endings for the logger.
# Logs plugin settings logs: (....) # Line ending # # Default: "\n". line_ending: "\n"
log_output: Filename is the file to write logs to in the same directory. It uses
processname-lumberjack.log in 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 compression.
log_ending: line ending to use in the logger. Default is new line -
In addition, you can configure each plugin log messages individually using
version: "2.7" 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
Feel free to register your own ZapLogger extensions.