Logging
Logging
The configuration file can be found at config/logging.rb
.
Overview
Logging (through the use of the logger
helper) will display a log message to STDOUT.
The logger has 6 severity levels:
To write a log message, simply do:
By default, only messages above (and equal to) the info
level will be displayed. This can be configured in the config/logging.rb
file.
Settings
The configuration file consists of a number of settings that can be used to adjust how logging works.
Environment-wide settings
The only setting that does not depend on the current environment is :log_directory_format
.
This setting specifies the DateTime
string format for the sub-directory of the logs
folder, where the current logs are being stored.
This defaults to %Y-%m-%d_%H-%M-%S
, giving a logs
folder structure like:
Environment-dependent settings
Logging can be fine-tuned according to the current environment.
The configuration file contains a configure
block for each environment. Each of these blocks can contain the following settings:
:logging
If set to
true
(either withset :logging, true
orenable :logging
), then logging is enabled via thelogger
helper method.When set to
true
, the logger's severity level is setINFO
by default.If set to
false
(either withset :logging, false
ordisable :logging
), then logging via thelogger
helper method is disabled - log messages get redirected to the system's null device.If set to a
Lumberjack::Severity
level (e.g.set :logging, Lumberjack::Severity::FATAL
, orset :logging, 4
), then logging is enabled via thelogger
helper method, which is configured to only display log messages of the specified severity or lower.
:log_file
If set to
true
(either withset :log_file, true
orenable :log_file
), thenSTDOUT
andSTDERR
will be redirected to log files.If set to
false
(either withset :log_file, false
ordisable :log_file
), thenSTDOUT
andSTDERR
will not be redirected to log files.
Last updated