Class SyslogLogger
In: lib/analyzer_tools/syslog_logger.rb
Parent: Object

SyslogLogger is a Logger work-alike that logs via syslog instead of to a file. You can add SyslogLogger to your Rails production environment to aggregate logs between multiple machines.

By default, SyslogLogger uses the program name ‘rails’, but this can be changed via the first argument to

NOTE! You can only set the SyslogLogger program name when you initialize SyslogLogger for the first time. This is a limitation of the way SyslogLogger uses syslog (and in some ways, a the way syslog(3) works). Attempts to change SyslogLogger’s program name after the first initialization will be ignored.

Sample usage with Rails


Add the following lines:

  require 'production_log/syslog_logger'


In 0.10.0, change this line:




Other versions of Rails should have a similar change.


Add the following lines:

 *.*                                             /var/log/production.log

Then touch /var/log/production.log and signal syslogd with a HUP (killall -HUP syslogd, on FreeBSD).


Add the following line:

  /var/log/production.log                 640  7     *    @T00  Z

This creates a log file that is rotated every day at midnight, gzip’d, then kept for 7 days. Consult newsyslog.conf(5) for more details.

Now restart your Rails app. Your production logs should now be showing up in /var/log/production.log. If you have mulitple machines, you can log them all to a central machine with remote syslog logging for analysis. Consult your syslogd(8) manpage for further details.


add   log_method   new   silence  


LOGGER_MAP = { :unknown => :alert, :fatal => :err, :error => :warning, :warn => :notice, :info => :info, :debug => :debug, }   Maps Logger warning types to syslog(3) warning types.
LOGGER_LEVEL_MAP = {}   Maps Logger log levels to their values so we can silence.
LEVEL_LOGGER_MAP = {}   Maps Logger log level values to syslog log levels.


level  [RW]  Log level for Logger compatibility.

Public Class methods

Builds a logging method for level meth.

Fills in variables for Logger compatibility. If this is the first instance of SyslogLogger, program_name may be set to change the logged program name.

Due to the way syslog works, only one program name may be chosen.

Public Instance methods

Almost duplicates Logger#add. progname is ignored.

Allows messages of a particular log level to be ignored temporarily.

Can you say "Broken Windows"?