6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sidekiq の ログの日付を日本標準時に変更する

Posted at

sidekiq のログフォーマットのカスタマイズ方法が github に記載されている。
完全に独自のフォーマットで出力したい場合には適当に MyFormatter を作ればよいが、日付の部分だけ変更したい場合には次のようにすれば良さそう。

config/initializers/sidekiq.rb
class MySidekiqFormatter < Sidekiq::Logging::WithoutTimestamp
  def call(severity, time, program_name, message)
    "#{time.localtime.iso8601(3)} #{super}"
  end
end

Sidekiq.configure_server do |config|
  Sidekiq::Logging.logger.formatter = MySidekiqFormatter.new
  config.redis = { url: 'redis://localhost:6379/0', namespace: "sidekiq_#{Rails.env}" }
end

Sidekiq.configure_client do |config|
  Sidekiq::Logging.logger.formatter = MySidekiqFormatter.new
  config.redis = { url: 'redis://localhost:6379/0', namespace: "sidekiq_#{Rails.env}" }
end

Sidekiq::Logging::WithoutTimestamp は sidekiq の lib/sidekiq/logging.rb を参照。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?