'Sidekiq Log Level not being set in production
I'm running Sidekiq with Rails 5.2.3 on AWS Elastic Beanstalk. Following the instructions in the Sidekiq wiki in initializers/sidekiq.rb I've set:
Sidekiq.configure_server do |config|
config.logger.level = Logger::WARN
end
This works in the development environment however in production Sidekiq is still generating logs at the debug level. The Rails production logger level is set to config.log_level = :warn
Solution 1:[1]
I had a similar, but opposite problem. My production log level was set to WARN, my Sidekiq log level was set to INFO, but I kept getting only WARN logs in production.
I finally figured out you must manually override the other loggers with Sidekiq.Logging
Sidekiq.configure_server do |config|
config.logger.level = Logger::WARN
Rails.logger = Sidekiq.logger
ActiveRecord::Base.logger = Sidekiq.logger
ActiveJob::Base.logger = Sidekiq.logger
end
Solution 2:[2]
To use a single environment variable to control both rails and sidekiq logging behaviour.
Sidekiq.configure_server do |config|
config.logger.level = Logger.const_get(ENV.fetch('LOG_LEVEL', 'info').upcase.to_s)
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ryan Romanchuk |
| Solution 2 | vishnu narayanan |
