Disable rails log for ActionCable events

流过昼夜 提交于 2019-12-22 03:16:48

问题


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?


回答1:


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

ActionCable.server.config.logger = Logger.new(nil)



回答2:


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.



来源:https://stackoverflow.com/questions/38366040/disable-rails-log-for-actioncable-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!