Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging configuration #3651

Closed
steveburkett opened this issue Nov 1, 2017 · 4 comments
Closed

logging configuration #3651

steveburkett opened this issue Nov 1, 2017 · 4 comments

Comments

@steveburkett
Copy link

steveburkett commented Nov 1, 2017

In our sidekiq server logs (sidekiq.log), i was finding that it's filling up with rails logging information. Setting

Sidekiq.configure_server do |config|
  config.redis = { url: redis_url }
  config.logger.level = ::Logger::INFO
end

failed to stop the flow of debug level rails logging into the sidekiq.log.

this worked better. does this look right? it seems odd to have to set both Rails.logger and ActiveRecord::Base.logger to the Sidekiq logger, but this is the only way i've found to have 1 server side logging setting to control the flow of logging.

Sidekiq.configure_server do |config|
  config.redis = { url: redis_url }
  config.logger.level = ::Logger::INFO

  Rails.logger = Sidekiq::Logging.logger
  ActiveRecord::Base.logger = Sidekiq::Logging.logger
end
@mperham
Copy link
Collaborator

mperham commented Nov 1, 2017

I don't know of any better way to do this. Expert opinions and cleaner options very welcome.

@mperham mperham closed this as completed Nov 1, 2017
@netwire88
Copy link

@mperham Is this still the correct way to set Sidekiq logging level in 2022? Or is it using Rails logging level now?

@mperham
Copy link
Collaborator

mperham commented May 15, 2022

Yes. Sidekiq.logger is the only supported API. Don’t use Sidekiq::Logging in your code.

@vishnu-narayanan
Copy link

@netwire88 I wanted to use a single environment variable to control both rails and sidekiq logging behaviour. This is working for me.

Sidekiq.configure_server do |config|
  config.logger.level = Logger.const_get(ENV.fetch('LOG_LEVEL', 'info').upcase.to_s)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants