Dave
Dave

Reputation: 19150

How do I add dates to my sidekiq.log log file?

I'm using Rails 5.0 with sidekiq on Ubuntu Linux. I start sidekick like so

cd $APP_ROOT && bundle exec sidekiq -d -P $SIDEKIQ_PID -L $APP_ROOT/log/sidekiq.log -c 1 -e $ENV

and have this in my config/initializers/sidekiq.rb file

Sidekiq.configure_server do |config|
  config.redis = { url: "redis://#{ENV['REDIS_PORT_6379_TCP_ADDR']}:#{ENV['REDIS_PORT_6379_TCP_PORT']}/12" }
end

Sidekiq.configure_client do |config|
  config.redis = { url: "redis://#{ENV['REDIS_PORT_6379_TCP_ADDR']}:#{ENV['REDIS_PORT_6379_TCP_PORT']}/12" }
end

Sidekiq.redis { |conn| conn.flushdb }

I notice though in my log/sideiiq.log file, my "puts" output statements from my Rails code appear as is, and I would like a date to appear in front of them. How can I change my configuration so that a date appears in front of each output line in my sidekiq log file?

Upvotes: 0

Views: 670

Answers (1)

Mike Perham
Mike Perham

Reputation: 22208

You have several options inside a Sidekiq worker:

def perform(args)
  logger.info "My message"
  Sidekiq.logger.info "Another"
  Rails.logger.info "Third!"
end

Upvotes: 1

Related Questions