I closed the log with `Syslog::close’. Is this the way you do it?
Thanks in advance!
I don’t bother. I generally use syslog with programs that run
indefinitely
and want the logging to continue until the system is rebooted or the
process is terminated on purpose.
So anything with a level of larger than or equal to notice will go to
/var/log/system.log
Testing:
$ uname -a
Darwin fwindt.lan 8.10.0 Darwin Kernel Version 8.10.0: Wed May 23
16:50:59
PDT 2007; root:xnu-792.21.3~1/RELEASE_PPC Power Macintosh powerpc
$ irb
reqirb(main):001:0> require ‘syslog’
=> true
irb(main):002:0> log = Syslog.open(‘progname’, Syslog::LOG_PID,
Syslog::LOG_LOCAL1)
=> <#Syslog: opened=true, ident=“progname”, options=1, facility=136,
mask=255>
irb(main):003:0> log.err(“my message”)
=> <#Syslog: opened=true, ident=“progname”, options=1, facility=136,
mask=255>
irb(main):004:0> exit
$ grep “my message” /var/log/syslog
Sep 2 13:25:13 fwindt-2 progname[891]: my message
You can redirect to special log files like this:
Looking through syslog.conf, it appears as if OS X only uses local0
(it’s
used for ipfw, the firewall). So you could use local1 as in the example,
and
edit your syslog.conf to contain a line such as “local1.*
/var/log/myapp.log” to have your logs written to that file as well. Just
to
mention it, there’s no way of keeping other apps from using that
facility as
well.
I believe you need to send a HUP to the syslog daemon for it to parse
changes to the config file.
HTH,
Felix
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.