Searching Rails logs - a few favorite queries - Papertrail Blog

The revolution will be verbosely {,b}logged

Searching Rails logs – a few favorite queries

Posted by Troy Davis on

A fringe benefit of using Papertrail for searching our logs all the time is that we get lots of experience creating queries. Here’s 5 that might be applicable to those with Ruby on Rails log files (like production.log), plus links to try them in your Papertrail account.

The best searches are always going to be the ones you create around your own logs or already use grep and tail for, but these are a start. And although these are are specific to Rails, the same data is logged by most Web frameworks.

1. Non-GET requests

What: Requests using common HTTP methods other than GET. For most Web apps, covers user logins, signups, and other form submissions (meaningful changes, searches).

Query: ” [POST]” OR ” [PUT]” OR ” [DELETE]” (Try it in your account)

2. Filtered form values

What: All form submissions with blocked values (passwords, credit cards)

Query: [FILTERED] (Try it)

3. Unusual HTTP responses

What: HTTP responses other than success (200) and temporary redirect (302). This includes 401 authentication required, 406 not acceptable, and anything else your app returns.

Query: “Completed in” -200 -302 (Try it)

4. Nonexistent paths

What: Requests for nonexistent paths that hit your Rails app (rather than for static assets)

Query: ActionController::RoutingError (Try it)

5. Exceptions

What: Logs related to exceptions, both user-facing and backend processing

Query: (exception OR Error) -Completed -Parameters (Try it)