Suppress Routing Errors for Missing Static Files


#1

Hello,

I’d like to know how I can suppress errors in the logs for routing
errors for missing files.

For instance, something like this:

[ERROR] application#index (ActionController::RoutingError) “no route
found to match “/release/record_cover/192/small/646.jpg” with
{:method=>:get}”

This is because a file is missing that is referenced on the page. We
have other methods to catch this and it is just cluttering up the
Rails log (and sending a ton of exception emails!) so I’d like to
disable them.

These are being reported at log level ‘info’.

Thanks,
Hunter


#2

Hunter H. wrote:

Hello,

I’d like to know how I can suppress errors in the logs for routing
errors for missing files.

For instance, something like this:

[ERROR] application#index (ActionController::RoutingError) “no route
found to match “/release/record_cover/192/small/646.jpg” with
{:method=>:get}”

This is because a file is missing that is referenced on the page. We
have other methods to catch this and it is just cluttering up the

What are these other methods?

You could have rescue_action_in_public(exception) check

  ActionController::UnknownController === exception || 

ActionController::UnknownAction === exception

and produce an error page, and have your own logging message (or none if
preferred).

Stephan

Rails log (and sending a ton of exception emails!) so I’d like to
disable them.

These are being reported at log level ‘info’.

Thanks,
Hunter


#3

Stephan W. wrote:

Hunter H. wrote:

Hello,

I’d like to know how I can suppress errors in the logs for routing
errors for missing files.

For instance, something like this:

[ERROR] application#index (ActionController::RoutingError) “no route
found to match “/release/record_cover/192/small/646.jpg” with
{:method=>:get}”

This is because a file is missing that is referenced on the page. We
have other methods to catch this and it is just cluttering up the

What are these other methods?

You could have rescue_action_in_public(exception) check

  ActionController::UnknownController === exception || 

ActionController::UnknownAction === exception

I forgot – plus, set the last entry in config/routes.rb like this.

map.catchall ‘*all’, :controller => ‘some_controller’, :action =>
‘not_found’

with this not_found method in your “some_controller”

def not_found
log_info(“Page not found: #{request.env[‘REQUEST_URI’]}”)
@page_title = “Page not found”
render :action => ‘no_such_page’, :layout=>‘external’, :status =>
404
end

The not_found rhtml gives useful error information, as usual.

But you seem to have your own method, that’s why I asked.

Stephan

and produce an error page, and have your own logging message (or none if
preferred).

Stephan

Rails log (and sending a ton of exception emails!) so I’d like to
disable them.

These are being reported at log level ‘info’.

Thanks,
Hunter