# Suppress Routing Errors for Missing Static Files

**URL:** <https://www.ruby-forum.com/t/suppress-routing-errors-for-missing-static-files/82283>\
**Category:** Rails\
**Created:** [January 18, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/suppress-routing-errors-for-missing-static-files/82283 "2007-01-18T19:16:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunter\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bc79bd/32.png) [@hunter\_h](https://www.ruby-forum.com/u/hunter_h)\
**Post date:** [January 18, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/suppress-routing-errors-for-missing-static-files/82283/1 "2007-01-18T19:16:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hunter\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bc79bd/32.png) [@hunter\_h](https://www.ruby-forum.com/u/hunter_h)\
**Post date:** [January 18, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/suppress-routing-errors-for-missing-static-files/82283/2 "2007-01-18T20:37:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hunter\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bc79bd/32.png) [@hunter\_h](https://www.ruby-forum.com/u/hunter_h)\
**Post date:** [January 18, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/suppress-routing-errors-for-missing-static-files/82283/3 "2007-01-18T21:23:30Z")

</div>

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
