forked from rails/exception_notification
-
Notifications
You must be signed in to change notification settings - Fork 424
Closed
Description
I created a notifier for ExceptionNotification that just pipes a few fields into a separate log file the idea being that after too many exceptions by a single IP in a short period of time fail2ban can kick in and ban the IP for a little while.
If you are interested I can submit a pull request, code is simple:
class Fail2banNotifier
def initialize(options)
@default_options = options
@default_options[:logfile] ||= Rails.root.join('log', 'fail2ban.log')
# Roll over every 30M, keep 10 files
@logger ||= Logger.new(@default_options[:logfile], 10, 30*1024*1024)
end
def call(exception, options={})
env = options[:env]
request = ActionDispatch::Request.new(env)
# <ip> : <exception class> : <method> <path> -- <params>
msg = "%s : %s : %s %s -- %s" % [
request.remote_ip,
exception.class,
request.request_method,
env["PATH_INFO"],
request.filtered_parameters.inspect
]
@logger.error(msg)
end
end
Metadata
Metadata
Assignees
Labels
No labels