shadabahmed / logstasher

Awesome rails logs
MIT License
821 stars 136 forks source link

Logging / not logging controller params hash #81

Open tamouse opened 9 years ago

tamouse commented 9 years ago

In https://github.com/shadabahmed/logstasher/pull/20 and the README indicating there might be issues with logging the params hash, I'm a bit concerned, as most of the problems I encounter have needed the params hash to discover the source of the errors. I don't want to explode my logs OR lose log records, neither is useful.

Is there an alternative I can use that let's me still view the params hash, but doesn't cause either of those problems to show up? For example, could I somehow have them logged simply as a custom value converted to a string?

ibrahima commented 8 years ago

I think one potential solution is to not enable parameter logging, but instead do something like this in your initializer: (ref #66)

fields[:params] = request.filtered_parameters.to_json

That should give you a json string instead of nested fields. But I'm not 100% sure if logstash won't try to parse that JSON, but my guess is that it shouldn't, because the second layer of JSON encoding should entity-ify the params JSON.