Syslog::Logger

By default, Syslog::Logger uses the program name
‘ruby’, but this can be changed via the first argument to ::new.

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

require'syslog/logger'log = Syslog::Logger.new'my_program'log.info'this line will be logged via syslog(3)'

Also the facility may be set to specify the facility level which will be
used:

log.info'this line will be logged using Syslog default facility level'log_local1 = Syslog::Logger.new'my_program', Syslog::LOG_LOCAL1log_local1.info'this line will be logged using local1 facility level'

You may need to perform some syslog.conf setup first. For a BSD machine
add the following lines to /etc/syslog.conf:

!my_program
*.* /var/log/my_program.log

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

If you wish to have logs automatically roll over and archive, see the
newsyslog.conf(5) and newsyslog(8) man pages.

Constants

Messages from Ruby applications are not considered as critical as messages
from other system daemons using syslog(3), so most messages are reduced by
one level. For example, a fatal message for Ruby’s Logger is considered an error for syslog(3).

Fills in variables for Logger compatibility. If
this is the first instance of Syslog::Logger,
program_name may be set to change the logged program name. The
facility may be set to specify the facility level which will
be used.