rails 7.2からrails 8.0への移行(アップデート、アップグレード)で必要な作業

wakairo @wakairo

Rails 8.0におけるlogger

config.loggerは、Railsアプリで用いるロガーの設定です。

rails newで生成されるconfig/environments/production.rbにおいて、 8.0からこの設定について以下の変更が行われました(この変更のPRその1PRその2)。この変更により、Kamralを用いたproduction環境ではタイムスタンプが二重に表示されなくなります。

-  # Log to STDOUT by default
-  config.logger = ActiveSupport::Logger.new(STDOUT)
-    .tap  { |logger| logger.formatter = Logger::Formatter.new }
-    .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
-
-  # Prepend all log lines with the following tags.
+  # Log to STDOUT with the current request id as a default log tag.
   config.log_tags = [ :request_id ]
+  config.logger   = ActiveSupport::TaggedLogging.logger(STDOUT)

既存アプリでも、production環境でタイムスタンプが二重になっている場合には、この変更を行ってタイムスタンプが1つになるようにすると良いかもしれません。

0
Raw
https://www.techtips.page/en/comments/663
❤️1
· 7137 views