Skip to content

Instantly share code, notes, and snippets.

@eric
Forked from mheffner/README.md
Created June 20, 2011 23:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric/1036903 to your computer and use it in GitHub Desktop.
Save eric/1036903 to your computer and use it in GitHub Desktop.
Setting up syslog logging on Heroku with Sinatra 1.2.x

Setting up syslog logging on Heroku with Sinatra 1.2.x

1. Update your Gemfile to include:

gem 'remote_syslog_logger'

3. Modify your config.ru to match the example one below.

4. Setup REMOTE_SYSLOG_URI environment variable

$ heroku config:add REMOTE_SYSLOG_URI=syslog://host.name.com:port

If you don't have a syslog target, get one for free from Papertrail.

That's it

On your next deploy you will be logging to that syslog host. Logs will use the hostname format: {APP_NAME}-{DYNO_NAME}.

require "rubygems"
require "bundler"
Bundler.require
if ENV['REMOTE_SYSLOG_URI']
require 'lib/remote_syslog'
uri = URI.parse(ENV['REMOTE_SYSLOG_URI'])
logger = RemoteSyslog:: UdpSender.new(uri.host, uri.port,
:local_hostname => "#{ENV['APP_NAME']}-#{ENV['PS']}")
use Rack::CommonLogger, logger
end
require "hello-world"
run HelloWorld::Application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment