When an ActiveRecord::RecordNotFound is raised in a Rails application a status code of 404 is returned to the client:
curl -I http://localhost:3000/users
HTTP/1.1 404 Not Found
But a status code of 500 is logged:
Started HEAD "/users" for 127.0.0.1 at 2012-09-14 22:11:54 +0200
Processing by UsersController#index as */*
Completed 500 Internal Server Error in 0ms
I would expect it to log the same HTTP status code in the log file as is returned to the user.
I've amended the Railties test so it shows the issue in this commit: jacobat@c9e4a4f
Okay. So. https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/log_subscriber.rb#L24 uses Rack::Utils::HTTP_STATUS_CODES, which defaults to 500 if it can't find the key. The status is 500 there already, though, so the error happens farther up. Hmmm.
I found the issue and submitted a PR.
log 404 status when ActiveRecord::RecordNotFound was raised (#7646)
Fixed by 8f0d332