how do I filter RoutingErrors and their long stack trace out of my log?
I am seeing several strange requests like this, with urls like /sitemap/, /google_sitemap.xml.gz, /sitemap.xml.gz, /google_sitemap.xml, /cgi-bin/awstat/awstats.pl, etc. The default rails behavior dumps these long stack traces into my log, like the following:
ActionController::RoutingError (No route matches "/rails/info/properties" with {:method=>:get}):
/dh/passenger/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/dh/passenger/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/dh/passenger/lib/phusion_passenger/railz/application_spawner.rb:400:in `start_request_handler'
/dh/passenger/lib/phusion_passenger/railz/application_spawner.rb:351:in `handle_spawn_application'
/dh/passenger/lib/phusion_passenger/utils.rb:184:in `safe_fork'
etc.
Is there any way to stop these long stack traces? I wouldn't mind the first line, the ActionController::RoutingError with the message and the url, but I'd like to get rid of the long开发者_Go百科 stack of passenger stuff.
Why don't you just set a default handler and not worry about the exceptions in the first place?
# Add at end of config/routes.rb
map.default '/*path', :controller => 'default', :action => 'not_found'
You can alter the parameters as required.
精彩评论