Disable BLOB Logging in Rails 3

Is there a way to disable / truncate BLOB fields in the requested SQL queries? When I insert or update a record with BLOB fields, in it the Rails logger prints the contents of these fields, which is very annoying. I found some solutions, but none of them work with Rails 3.

+4
source share
1 answer

I think there are a few things you can do, one could override the Logger format_message function and remove the BLOB fields from the log message:

class Logger
  def remove_blobs msg
    ...
  end

  def format_message(severity, timestamp, progname, msg)
    "#{remove_blobs msg}\n"
  end
end

Next up is adding the blob fields to the filter_parameters parameters in the application.rb file. This would mean that the blob fields would be completely filtered out from the application logs:

config.filter_parameters += [:blob_field1, :blob_field2]

, , logging, .

+1

All Articles