9

i made a distribuited real-time system in RoR, it's compose by 2 machine.

PC A: take images from a Camera and send these to the second PC. So this machine send every second an http request with the image in the params. PC B - the server: save the image in a database.

My problem is that the log file become too big because log even the params string. How can i set the logger to truncate the params? or simply remove it?

sorry for my bad english..... i hope that someone can help me. Bye Davide Lentini.

Dabidi
  • 397
  • 5
  • 14

2 Answers2

25

To specifically remove certain params from the logs you can set the config.filter_parameters in application.rb like this:

config.filter_parameters += [:parameter_name]

This will replace the value of the filtered parameter with "[FILTERED]".

CMW
  • 3,093
  • 1
  • 16
  • 20
  • 4
    Adding quick reference for those who find this answer in the future: http://api.rubyonrails.org/classes/ActionDispatch/Http/FilterParameters.html – Oli Jul 09 '13 at 15:41
  • this is for which version on rails? – Arnold Roa Apr 08 '18 at 02:36
  • As far as I know this has been around for the last six years. It's still in the current edgerails guides. I think this must have been around at least since rails 2.1.0. – CMW Apr 14 '18 at 22:06
  • 1
    You can also specify lambda, as seen from Oli's link. – x-yuri Jun 11 '18 at 15:33
6

You can set the log level to be less verbose.

See the rails guide on debugging.

So for your entire application (in development), add this to config/environments/development.rb:

config.log_level = :warn # In any environment initializer, or

Or, to change the logging level directly in your application:

Rails.logger.level = 0 # at any time
ipd
  • 5,674
  • 3
  • 34
  • 49