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.