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

Enable lograge at all times, improve output for grape

Oliver Günthere7fe9c8a2fe3
diff --git a/config/application.rb b/config/application.rb
index 4dd4e0e0393..136fbe7bd0d 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -84,7 +84,9 @@ module OpenProject
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
- config.logger = ActiveSupport::TaggedLogging.new(logger)
+ # Prepend all log lines with the following tags.
+ config.log_tags = [:request_id]
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Use Rack::Deflater to gzip/deflate all the responses if the
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rb
index 9396a0fe2d5..4c9f031867a 100644
--- a/config/constants/settings/definition.rb
+++ b/config/constants/settings/definition.rb
@@ -590,10 +590,15 @@ module Settings
log_requesting_user: {
default: false
},
- # Use lograge to format logs, off by default
- lograge_formatter: {
+ lograge_enabled: {
description: 'Use lograge formatter for outputting logs',
- default: nil,
+ default: true,
+ format: :boolean,
+ writable: false
+ },
+ lograge_formatter: {
+ description: 'Lograge formatter to use for outputting logs',
+ default: 'key_value',
format: :string,
writable: false
},
diff --git a/config/environments/production.rb b/config/environments/production.rb
index b6452c0e16d..3dfa24de6a6 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -105,9 +105,6 @@ OpenProject::Application.configure do
config.assets.quiet = true unless config.log_level == :debug
- # Prepend all log lines with the following tags.
- config.log_tags = [:request_id]
-
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb
index 8d5c49137c4..bd21de8df7b 100644
--- a/config/initializers/lograge.rb
+++ b/config/initializers/lograge.rb
@@ -2,6 +2,7 @@ Rails.application.configure do
next unless OpenProject::Logging.lograge_enabled?
config.lograge.enabled = true
+ config.lograge.keep_original_rails_log = Rails.env.development?
config.lograge.formatter = OpenProject::Logging.formatter
config.lograge.base_controller_class = %w[ActionController::Base]
diff --git a/lib/open_project/logging.rb b/lib/open_project/logging.rb
index 076d8a7f2fd..1ca5afa1219 100644
--- a/lib/open_project/logging.rb
+++ b/lib/open_project/logging.rb
@@ -6,7 +6,7 @@ module OpenProject
##
# Do we use lograge in the end to perform the payload output
def lograge_enabled?
- OpenProject::Configuration.lograge_formatter.present?
+ OpenProject::Configuration.lograge_enabled?
end
##