No commit activity in last 3 years
No release in over 3 years
A simple wrapper to use Rails Tagged Logging with Syslog
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

rails-tagged-syslog

https://github.com/abril/rails-tagged-syslog

Description

This is a simple wrapper to integrate Rails Tagged Logging with Syslog, this way you can benefit from rails tagged logging with the power provided by the syslog system.

Install

$ gem install rails-tagged-syslog

or via Gemfile

gem 'rails-tagged-syslog'

Usage

Rails config

config.logger = Abril::TaggedSyslog.new

By default it will add the request ID, as a tag, to your logs, but you can also add more tags using the default rails mechanism

config.log_tags = [:remote_ip, -> request { request.env['yourapp.someid'] }]

Syslog config

BSD Syslog Setup

/etc/syslog.conf

Add the following lines:

  !rails
  *.*                                             /var/log/production.log

Or, in Mac OS X:

  local7.*                                        /var/log/production.log

Then touch /var/log/production.log and signal syslogd with a HUP

$ killall -HUP syslogd
/etc/newsyslog.conf

Add the following line:

  /var/log/production.log                 640  7     *    @T00  Z

This creates a log file that is rotated every day at midnight, gzip'd, then kept for 7 days. Consult newsyslog.conf(5) for more details.

Syslog-ng Setup

syslog-ng.conf

A basic setup:

  destination rails_log { file("/var/log/production.log"); };
  filter f_rails { program("rails.*"); };
  log { source(src); filter(f_rails); destination(rails_log); };

A more advanced setup with formatting, etc:

  destination rails { file("/var/log/rails_apps" owner("rails") group("rails") perm(0664) template("$DATE $HOST $PROGRAM [$LEVEL] $MSGONLY\n") template_escape(no) ); };
  filter f_rails    { (program("railsappone") or program("railsapptwo")) and not match("SQL ") and not match("SELECT") and not match("INSERT INTO") and not match("UPDATE"); };
  log { source(src); filter(f_rails); destination(rails); };