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:
logger.unknown # Highest priority
logger.fatal # |
logger.error # |
logger.warn # |
logger.info # V
logger.debug # Lowest priorityTo write a log message, simply do:
logger.info "This is a non-severe message."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:
logs
├── 2018-08-21_20-26-23
│ ├── production.stderr.log
│ └── production.stdout.log
└── 2018-08-21_20-26-41
├── development.stderr.log
└── development.stdout.logEnvironment-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:
:loggingIf set to
true(either withset :logging, trueorenable :logging), then logging is enabled via theloggerhelper method.When set to
true, the logger's severity level is setINFOby default.If set to
false(either withset :logging, falseordisable :logging), then logging via theloggerhelper method is disabled - log messages get redirected to the system's null device.If set to a
Lumberjack::Severitylevel (e.g.set :logging, Lumberjack::Severity::FATAL, orset :logging, 4), then logging is enabled via theloggerhelper method, which is configured to only display log messages of the specified severity or lower.
:log_fileIf set to
true(either withset :log_file, trueorenable :log_file), thenSTDOUTandSTDERRwill be redirected to log files.If set to
false(either withset :log_file, falseordisable :log_file), thenSTDOUTandSTDERRwill not be redirected to log files.
Last updated