Disable rails log for ActionCable events

2019-04-21 04:28发布

In development environment, rails logger logs all ActionCable events which is sometimes annoying (for my project, every now and then it's transmitting messages and log tail is running like wild horse). What is an efficient way to suppress all event logs from ActionCable? Also, how can I suppress some specific ActionCable events?

2条回答
霸刀☆藐视天下
2楼-- · 2019-04-21 04:38

Same here, finally I found a solution. You should override a code in /app/channels/application_cable/channel.rb as follows

module ApplicationCable

  class Channel < ActionCable::Channel::Base

    def dispatch_action(action, data)

      #logger.info action_signature(action, data)

      if method(action).arity == 1
        public_send action, data
      else
        public_send action
      end
    end
  end
end

You can simulate the original behavior by uncommenting out #logger.info action_signature(action, data) line.

Thanks.

查看更多
小情绪 Triste *
3楼-- · 2019-04-21 04:50

To completely disable logging from ActionCable you should configure ActionCable to use logger that do nothing

ActionCable.server.config.logger = Logger.new(nil)
查看更多
登录 后发表回答