Get a List of Bad Links from Rails Log

By: Johnathon Wright on: October 22, 2009

If you have a Ruby on Rails app and you want to generate a list of the URLs that have generated 404s from your logs, here's one way:


perl -n -e '/No route matches "(.)" with ./&&print "$1\n"' log/production.log | sort | uniq>public/bad_paths.txt

then view: http://productionsite/badpaths.txt

We're using Passenger, and I'm not sure to what extent passenger is involved in the format of the Rails logs -- I would assume it's not, that wouldn't be very Railsy, but if it doesn't work, that might have something to do with it.

Anyway, unix is cool.





Comments:

Just checking that you are human. What would be the result of this code?

a = 3*(4/2); b = 1; a+b

Nana said: Billie Eilish - the youngest person and second person ever to win the four main Grammy categories, was born in December 18, 2001, find out more about her net worth on celebrity networth
Back