Skip to content

Instantly share code, notes, and snippets.

Created February 9, 2012 10:25
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nofxx/1779106 to your computer and use it in GitHub Desktop.
Resque syslog (via log4r)
require 'log4r'
require 'log4r/outputter/syslogoutputter'
require 'resque/failure/multiple'
require 'resque/failure/redis'
module Resque
module Failure
class Syslog < Base
# Define your logger, change as needed.
def logger
unless @logger
@logger = 'resque'
@logger.outputters = 'resque',
:ident => 'resque', :logopt => 'foo', :facility => 'local'
# We are using a two line log here: Resume and backtrace follow.
def save
logger.error "#{worker} #{queue} #{payload} #{exception.class}"
logger.error "#{exception} -- #{exception.backtrace.join('\n')}"
# Use multiple failure backends (Redis and Syslog)
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Syslog]
Resque::Failure.backend = Resque::Failure::Multiple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment