How to disable logging for ActionController::RoutingError Errors?
My production log file is full of bots searching for phpMyAdmin and other stuff.
Then the real application errors are overlooked.
Please help. I'm running Rails 3.2 and Passenger.
In my routes.rb I map all other urls to get ":code" => "shared#code"
, and then, if not found, i display a page with message. But when the bot search for urls like http://mywebsite.com/phpMyAdmin/index.php
, the classic error page is shown "The page you were looking for doesn't exist.". Which is ok. But i just dont want to log these errors in the log file.
The thing that logs/displays errors is the ActionDispatch::DebugExceptions
middleware. You could just overwrite the log_error
method, for example stick this in an initialiser:
class ActionDispatch::DebugExceptions
alias_method :old_log_error, :log_error
def log_error(env, wrapper)
if wrapper.exception.is_a? ActionController::RoutingError
return
else
old_log_error env, wrapper
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With