I am very new playing with syslog.
We have decided to use syslog to track some special events in our Rails application.
The problem is that I don't want to use the default /var/log/system.log
file but use a custom one like /var/log/myapp_events.log
.
I see that for that I have to define my own facility in /etc/syslog.conf
like this:
myapp_events.* /var/log/myapp_events.log
After restarting syslogd I see that I can play with it directly into the bash console:
syslog -s -k Facility myapp_events Message "this is my message"
The message appears into the /var/log/myapp_events.log
as expected, but I cannot reproduce this behavior using the syslog ruby gem. I have tried:
require 'syslog'
Syslog.open('myapp_events', Syslog::LOG_PID | Syslog::LOG_CONS) { |s| s.warning 'this is my message' } # sends the message to system.log
Syslog.open('myapp_events', Syslog::LOG_PID | Syslog::LOG_CONS, 'myapp_events') { |s| s.warning 'this is my message' } # error because 'myapp_event' can't be converted to int.
I see that Syslog.open
has a third argument which is the facility but it has to be an integer and what I have is a string.
Any suggestion?