Disable BLOB logging in Rails 3
Is there a way to disable/truncate BLOB fields in the logged SQL queries? When I insert or update a record wi开发者_JS百科th BLOB fields in it Rails logger prints the contents of these fields which is very annoying. I found some solutions but none of them work with Rails 3.
I think there are a couple of things you can do, one would be to override the Logger format_message function and remove BLOB fields from the logger message:
class Logger
def remove_blobs msg
...
end
def format_message(severity, timestamp, progname, msg)
"#{remove_blobs msg}\n"
end
end
The next would be to add your blob fields to the filter_parameters in your application.rb file. This would mean that the blob fields would be filtered from your application logs entirely:
config.filter_parameters += [:blob_field1, :blob_field2]
Finally, you could look into some other logging gems, like logging, to add further customization to your logs.
精彩评论