Store deprecation warnings to a separate file

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Upgrading to new versions of rails brings many deprecation warnings that blow both development and test logs.
It's hard to read useful information among tons of deprecation warnings.

My proposal is to store deprecation warnings to a separate file, e.g.

diff --git a/config/environments/test.rb b/config/environments/test.rb
index 3461099253a..411958d941c 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -38,7 +38,10 @@ Rails.application.configure do
   config.action_mailer.delivery_method = :test
 
   # Print deprecation notices to the stderr
-  config.active_support.deprecation = :stderr
+  config.active_support.deprecation = ->(message, _callstack) {
+    log_file = Rails.root.join("log", "deprecations.log")
+    Logger.new(log_file).warn(message)
+  }
 
   config.eager_load = false
 
(END)

And we could add a CI job that would check deprecations.log and warn developers there may be potential problems in the future.

Thoughts? 🙂

@stanhu @godfat @rymai @DouweM @smcgivern @jprovaznik

Edited Jun 27, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading