Reputation:
How can I remove this active-model-serializers message from my logs?
[active_model_serializers] Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::JsonApi
Upvotes: 6
Views: 2488
Reputation: 1083
Since mid-2018, the correct way to do this is in your config/initializers/active_model_serializer.rb
is now:
ActiveModelSerializers.logger = Logger.new(IO::NULL)
Upvotes: 0
Reputation: 5575
In your config/initializers/active_model_serializer.rb
:
require 'active_model_serializers'
ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)
This properly unsubscribes you from the rendering event, as opposed to just disabling all logging, etc. from: https://github.com/rails-api/active_model_serializers/blob/ab98c4a664f26077e5b3c90ea6bcbe129ec2d0b9/docs/general/logging.md
Upvotes: 11
Reputation: 3080
I haven't found anything in AMS configuration to disable logs, however, there are several other ways of achieving this by redefining ActiveModelSerializers.logger
(source)
in your config/initializers/active_model_serializer.rb
:
1) Increase the log level so that nothing will get logged:
ActiveModelSerializers.logger.level = Logger::Severity::UNKNOWN
or
2) Write AMS log to /dev/null
ActiveModelSerializers.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new('/dev/null'))
Upvotes: 1