{"record":{"id":"03fd56f14e1a3ee5","repo":"roidrage/lograge","slug":"config-lograge-log-format-is-deprecated-use-confi","errorCode":null,"errorMessage":"config.lograge.log_format is deprecated. Use config.lograge.formatter instead.","messagePattern":"config\\.lograge\\.log_format is deprecated\\. Use config\\.lograge\\.formatter instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/lograge.rb","lineNumber":220,"sourceCode":"\n    require 'lograge/rails_ext/action_cable/server/base' if defined?(ActionCable)\n\n    Lograge.remove_existing_log_subscriptions\n  end\n\n  def rack_cache_hashlike?(app)\n    app.config.action_dispatch.rack_cache&.respond_to?(:[]=)\n  end\n  private_class_method :rack_cache_hashlike?\n\n  # TODO: Remove with version 1.0\n\n  def support_deprecated_config\n    return unless lograge_config.log_format\n\n    legacy_log_format = lograge_config.log_format\n    warning = 'config.lograge.log_format is deprecated. Use config.lograge.formatter instead.'\n    deprecator.warn(warning, caller)\n    legacy_log_format = :key_value if legacy_log_format == :lograge\n    lograge_config.formatter = \"Lograge::Formatters::#{legacy_log_format.to_s.classify}\".constantize.new\n  end\n\n  def lograge_config\n    application.config.lograge\n  end\n\n  def deprecator\n    @deprecator ||= ActiveSupport::Deprecation.new('1.0', 'Lograge')\n  end\n\n  if ::ActiveSupport::VERSION::MAJOR >= 8 ||\n     (::ActiveSupport::VERSION::MAJOR >= 7 && ::ActiveSupport::VERSION::MINOR >= 1)\n    def notification_listeners_for(name)\n      ActiveSupport::Notifications.notifier.all_listeners_for(name)\n    end\n  else","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/roidrage/lograge/blob/e5caed777529668269c32d78ca9de4b86a4fe23a/lib/lograge.rb#L202-L238","documentation":"lograge is a Rails gem that collapses verbose multi-line request logs into single-line output. This message is an ActiveSupport::Deprecation warning (horizon 1.0, lib/lograge.rb:229-231) emitted once at Rails boot when an initializer sets the legacy key config.lograge.log_format instead of config.lograge.formatter. A compatibility shim (support_deprecated_config, marked 'TODO: Remove with version 1.0' at lib/lograge.rb:213) still honors the old key by mapping the symbol to a formatter class: :lograge becomes Lograge::Formatters::KeyValue and :json becomes Lograge::Formatters::Json. It is non-fatal today, but in lograge 1.0 the shim is deleted and log_format will be silently ignored, so log output reverts to the default format.","triggerScenarios":"Booting any Rails process (server, console, rake task, rails runner) where an initializer sets config.lograge.log_format to a truthy value — typically :json, :raw, or :lograge — in config/initializers/lograge.rb, config/application.rb, or config/environments/production.rb. The lograge railtie runs support_deprecated_config during initialization (lib/lograge.rb:216) and calls deprecator.warn with the message plus a caller backtrace pointing at your initializer.","commonSituations":"Initializers copied from older blog posts or other apps written against pre-formatter lograge; apps upgrading lograge across the release that introduced config.lograge.formatter; production apps whose log ingest (ELK, Fluentd, Datadog) depends on JSON lines and would silently lose structured output after a future upgrade to lograge 1.0; noisy CI logs when ActiveSupport deprecation behaviors are set to :log or :stderr.","solutions":["In the file flagged by the warning's caller backtrace, replace `config.lograge.log_format = :json` with `config.lograge.formatter = Lograge::Formatters::Json.new`.","If you used `log_format = :lograge`, switch to `config.lograge.formatter = Lograge::Formatters::KeyValue.new` — that is the exact legacy mapping (lib/lograge.rb:221).","If you used `:raw`, use `Lograge::Formatters::Raw.new`; any other symbol X maps to `Lograge::Formatters::X.classify`, so prefer the explicit class instance instead.","Search the whole config tree for stray copies: `grep -rn \"log_format\" config/` — environment-specific files often carry a second one.","For custom output, pass any object responding to call(severity, time, progname, msg) — a lambda or a Lograge::Formatters::Base subclass instance — as config.lograge.formatter.","Reboot and verify: `bin/rails runner 'puts Rails.application.config.lograge.formatter.class'` — the deprecation warning must be gone and log lines unchanged."],"exampleFix":"# before (config/initializers/lograge.rb)\nRails.application.configure do\n  config.lograge.enabled = true\n  config.lograge.log_format = :json\nend\n\n# after\nRails.application.configure do\n  config.lograge.enabled = true\n  config.lograge.formatter = Lograge::Formatters::Json.new\nend","handlingStrategy":"validation","validationCode":"# Fail fast at boot or in CI if the deprecated key is still set:\nif Rails.application.config.lograge.log_format\n  abort 'config.lograge.log_format is deprecated and will be ignored in lograge 1.0 — set config.lograge.formatter instead'\nend\n# One-liner for CI: bin/rails runner 'abort \"deprecated lograge log_format set\" if Rails.application.config.lograge.log_format'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the warning as a blocker, not noise: it names a removal version (lograge 1.0), after which the key is silently ignored and structured log pipelines break.","After upgrading lograge, grep config/ for removed keys (`grep -rn \"log_format\" config/`) and read the CHANGELOG for config renames.","Write initializers from the gem's current README rather than old tutorials; copy-pasted config is the main source of this warning.","Run a boot smoke test in CI (bin/rails runner 'exit') with deprecation warnings visible so config drift surfaces before deploy.","Pin the lograge version in the Gemfile so a transitive bump cannot delete the shim before your config is updated."],"tags":["lograge","rails","ruby","deprecation","logging","configuration"],"backgroundTag":"rails-deprecation-warning","analyzedSha":"e5caed777529668269c32d78ca9de4b86a4fe23a","analyzedAt":"2026-08-23T09:39:50.982Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}