# HOWTO: remote logging with syslog-ng

**URL:** <https://www.ruby-forum.com/t/howto-remote-logging-with-syslog-ng/82482>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/howto-remote-logging-with-syslog-ng/82482 "2007-01-19T16:30:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quangn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/e47774/32.png) [@quangn](https://www.ruby-forum.com/u/quangn)\
**Post date:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/howto-remote-logging-with-syslog-ng/82482/1 "2007-01-19T16:30:49Z")

</div>

I wrote this up for my own use, and I thought I would share it here.  
This is for syslog-ng, the configuration is very different for syslogd.  
syslog-ng comes default on Arch Linux, I’m not sure what other distros  
it comes on stock.

To log to syslog-ng with Rails and lighttpd:

First, install the analyzer tools to get the SyslogLogger class:  
gem install rails\_analyzer\_tools

Then, add to your environment.rb:  
require ‘analyzer\_tools/syslog\_logger’

Then in the config section(or in enviroments/production.rb):  
config.logger = SyslogLogger.new  
#config.log\_level = :warn – this doen’t apply when using syslog.

# You have to filter the level in your syslog config.

Add to /etc/syslog-ng.conf on the system to log FROM:  
destination remote { udp("[machine to log to]" port(5140)); };  
filter f\_rails { program(rails) and level(warn…emerg); };  
log { source(src); filter(f\_rails); destination(remote); };  
filter f\_lighttpd { program(lighttpd); };  
log { source(src); filter(f\_lighttpd); destination(remote); };

Add to /etc/syslog-ng.conf on the system to log TO:  
These can be all together for simplicity’s sake instead of separated out  
like the other entries.  
Note that the IP here is this machine’s IP, the same IP as used in the  
client machine’s configuration.  
source r\_src { udp(ip("[local machine’s IP]") port(5140)); };  
destination rails { file("/var/log/rails.log"); };  
destination lighttpd { file("/var/log/lighttpd.log"); };  
log { source(r\_src); filter(f\_rails); destination(rails); };  
log { source(r\_src); filter(f\_lighttpd); destination(lighttpd); };  
filter f\_rails { program(rails); };  
filter f\_lighttpd { program(lighttpd); };

Restart syslog-ng and you’re done!

Hope this can help someone as I found documentation on this sparse out  
on the interweb.

-Jason
