I'm very new playing with syslog.
We have decide to use syslog to track some especial events on our Rails application.
The point 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 into the /etc/syslog.conf
like this:
myapp_events.* /var/log/myapp_events.log
After restart syslogd I see 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 can not 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 wich is the facility but it has to be an integer and what I have is an string.
Any suggestion?