I was working on a Rails application recently that required the logs to be sent to remote log server. This blog is just a summary of the steps to get it working. I used Rails 2.0 and the development was done on Ubuntu.

The first thing was to get syslog-ng. Its more advanced than syslogd.

sudo apt-get install syslog-ng

The next step was to get the SysLogLogger tool to send the logs to syslog instead of a file. Go to the vendor directory of your application and get SysLogLogger using the following command.

curl http://rubyforge.org/frs/download.php/20520/SyslogLogger-1.4.0.tgz
-L | tar -zxvv

Assuming that you are working in the development environment , add this to the start of the development.rb file in the configuration directory

$:.unshift File.join(RAILS_ROOT, "vendor", "SyslogLogger-1.4.0", "lib")
require 'syslog_logger'
RAILS_DEFAULT_LOGGER = SyslogLogger.new(program_name = 'my-application')
config.logger = RAILS_DEFAULT_LOGGER

Locate the syslog.conf file in the etc directory and add these lines.

user.* /var/log/development.log

What this does is gets the logs that are sent to syslog from the rails application and writes it to the development.log file in /var/log/ dir

To get the changes working, restart the syslog service on Ubuntu by running the following command
sudo /etc/init.d/sysklogd restart

To send the logs to a remote log server instead of the log file use this in the syslog.conf file instead
user.* @address of remote log server

The log server should be configured to accept logs from remote systems. The syslogd file in the remote log server needs to be changed to show the following for this purpose


The syslogd file is located in the etc/default dir in Ubuntu. Since I had the log server configured already, I did not need to change the configuration. Please add comments on this post in case something is missing.

The log files can be rotated on a periodic basis (or depending on size) by configuring the logrotate.conf file in the etc dir.
See man logrotate for details.


Its been sometime I have been working with Ruby and Rails. It was more of Ruby and less of Rails until now. We are building a restful service in rails that would be called by Java. It was this opportunity that made me look at The Rails Way by Obie Fernandez. I must admit I got caught right from the beginning. I am in the second chapter now and the author knows what he is talking about. I would not recommend this book for a person who is starting on Rails but this is a keeper for any Rails reference. (thats what I think so far). I took a glance at the part where he talks about nginx. Not much on that either. I think it would be best to use “Agile Web Development with Rails” to begin with, this book as a reference and Ezra’s book for deployment. (my two cents).

The part that I like most in the introduction is where Obie mentions the problems being faced in enterprise software development (Legacy Systems, Business Analysts, resistant managers, politics). There are two solutions to these problems. The first is to play safe and the second is an alternative to the first one. Here is what he says —

That alternative is being exceptional ! It starts with productivity. I am talking about being so obviously effective at your job that nobody will ever be able to scapegoat you, to the extent that it would be political suicide to try.

The first two chapters talk about configuration and controllers. Each part in that chapter has some information that is new to me. Not being an expert in Ruby and Rails has made me jump back and forth between this book and the ones from Pragmatic Programmers. But, so far I have enjoyed reading it.