Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use tagged logger with timestamp formatting as early as possible (#9178)

Oliver Güntherd98f08b7db33
diff --git a/config/application.rb b/config/application.rb
index 492d15adfe9..1fb51ae1454 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -66,6 +66,19 @@ module OpenProject
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
+ # Sets up logging for STDOUT and configures the default logger formatter
+ # so that all environments receive level and timestamp information
+ #
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Set up STDOUT logging if requested
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
# Use Rack::Deflater to gzip/deflate all the responses if the
# HTTP_ACCEPT_ENCODING header is set appropriately. As Rack::ETag as
# Rack::Deflater adds a timestamp to the content which would result in a
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 6ccc63d1ac3..c6facbd516c 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -119,15 +119,6 @@ OpenProject::Application.configure do
# Disable automatic flushing of the log to improve performance.
config.autoflush_log = false
- # Use default logging formatter so that PID and timestamp are not suppressed.
- config.log_formatter = ::Logger::Formatter.new
-
- if ENV["RAILS_LOG_TO_STDOUT"].present?
- logger = ActiveSupport::Logger.new(STDOUT)
- logger.formatter = config.log_formatter
- config.logger = ActiveSupport::TaggedLogging.new(logger)
- end
-
config.active_record.dump_schema_after_migration = false
if OpenProject::Configuration.enable_internal_assets_server?