#Logging
#Logging from within jobs
All your jobs have access to a standard Ruby logger.
#Logging from other classes
In case you need access to the logger from other classes (that do not inherit from Jobly::Job
), you can include the Jobly::Logging
module (or the more inclusive Jobly::Helpers
module).
#Configuring the logger
By default, output is sent to STDOUT
but you can provide your own logger and log to a file or to syslog by using the config.log
or the config.logger
option in ./config/jobly.rb
The config.log
option controls how logging is handled.
- If left empty (
nil
), the web server and workers will NOT log anywhere, and your jobs will log toSTDOUT
whenever you uselogger
. - Setting it to
config.log = 'stdout'
will also instruct the web server and worker to send their logging toSTDOUT
. - Setting it to a filename, will log to a file.
- Setting it to a syslog connection string will log to a remote syslog server.
#Logging to syslog
Set config.log
to a syslog connection string in the following format:
Omitting any of the options will fall back to a sensible default.
See the Syslog Example for mode details:
#Separate log files for each job class
If Jobly.log
contains %s
in the file path, it will be replaced with the slug of the job, and will create separate log files for each job class.
#Automatic syslog tagging
The same %s
replacement principle applies when using a syslog connection string. This is intended to allow tagging of syslog messages with the job name.
#Bring your own logger
The config.log
option can also accept any Logger
instance, in case you wish to provide a custom logger.