views:

30

answers:

1

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 stack of passenger stuff.

+1  A: 

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.

tadman
I've tried this but it's not even getting to my controller. Does the `map.default` indicate a special kind of named route? My route is `map.default '*', :controller => 'error', :action => 'route_not_found'` and my Controller is ErrorsController
You should be able to call it whatever you want. Make sure the route shows up properly in the output of 'rake routes'. When you access that path, what controller shows up in your log of the decoded request?
tadman