Filter Sensitive Data From Your Logs

by Brian on 3/25/2008

The production.log file is a very useful tool for troubleshooting problems with your Rails applications. Come on, I bet everyone gets an email from a customer that says, “ya, there was a problem with the page.” And of course their description of the problem stops there. What were you doing? What page were you viewing? Anything useful??? Looking at the production.log file helps in that you can search for the last exception thrown by your app and start troubleshooting form there (you also have the params submitted, as well as the controller and action that threw the error). I’m sure people have made many scripts to find the most recent errors for you.

However, an important thing to remember if you’re using Rails is to make sure you filter out sensitive data from your production.log file. What’s the point of using SSL if all the credit card numbers sent to your site are stored in a plan text file that could easily be stolen? The solution to the problem is quite simple, just add one line to your controller:

filter_parameter_logging :credit_card

“credit_card” can be the name of any key in your params hash.

Related posts:

  1. An Error Caused By Not Missing a Constant
  2. Generating Schema from Existing Database
  3. ATC Recording of Air Force One Landing in Ottawa
  4. Offline Google Ads
  5. Sudoku Results
blog comments powered by Disqus

Previous post:

Next post: