【问题标题】:Redis equivalent of ActiveRecord::Base.logger = Logger.new(STDOUT)?Redis 相当于 ActiveRecord::Base.logger = Logger.new(STDOUT)?
【发布时间】:2011-10-22 02:24:50
【问题描述】:

ActiveRecord::Base.logger = Logger.new(STDOUT) 的 redis 等价物是什么?我想看看redis在做什么。

【问题讨论】:

    标签: ruby redis


    【解决方案1】:

    $redis.client.logger = Rails.logger

    这样更好!

    【讨论】:

      【解决方案2】:

      我通常想设置一些额外的属性(例如redis DB名称)。您可以像这样在初始化方法中传递参数

      $redis = Redis.new(db: Rails.config.redis.db, logger: Rails.logger)
      

      【讨论】:

        【解决方案3】:

        没关系。很简单:

        $redis = Redis.new(:host => 'localhost', :port => 6379)
        $redis.client.logger = Logger.new(STDOUT)
        

        【讨论】:

          【解决方案4】:

          我写了一个gem调用RedisLogger:

          https://github.com/hellolucky/redis_logger

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-01-13
            • 2012-06-22
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多