sidekiq icon indicating copy to clipboard operation
sidekiq copied to clipboard

Allow user to disable default job logging

Open mperham opened this issue 1 year ago • 1 comments
trafficstars

This PR adds a new configuration knob, :skip_default_job_logging, to disable job logging out of the box, see #6199.

The user can choose when and where to disable the logging. I would recommend leaving it enabled for a reasonable developer experience but in environments like a high-volume production setup, logging output can be significant. This allows the user to opt-out of the logging if it becomes an issue.

Sidekiq.configure_server do |config|
  # disable job logging in production
  config[:skip_default_job_logging] = (config[:environment] == "production")

  # disable sidekiq's job logging everywhere
  config[:skip_default_job_logging] = true
end

mperham avatar Feb 16 '24 23:02 mperham

This does change the JobLogger constructor. Since that's a breaking change to an internal component, it'll need a minor version bump to 7.3.0.

mperham avatar Feb 16 '24 23:02 mperham

Is there any reason why the config.skip_default_job_logging = true syntax doesn't work here? Seems out of place with the rest of the config:

  config.redis = Redis.config_sidekiq

  config.logger = Sidekiq::Logger.new($stdout)
  config.logger.level = ENV.fetch('SIDEKIQ_LOG_LEVEL', 'info')
  config[:skip_default_job_logging] = (config[:environment] == 'production')
  
  config.super_fetch!
  config.reliable_scheduler!

sirwolfgang avatar Jul 09 '24 08:07 sirwolfgang

Yes, it was not deemed important enough option to justify accessors on Sidekiq::Config.

mperham avatar Jul 09 '24 13:07 mperham

will this work with version 6.1.2 ?

ahmedsayedabdelsalam avatar Aug 06 '24 15:08 ahmedsayedabdelsalam