diff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rb index 31a9bc28224..3fc133d139f 100644 --- a/config/initializers/101-lograge.rb +++ b/config/initializers/101-lograge.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true -if (Rails.env.production? && SiteSetting.logging_provider == "lograge") || - (ENV["ENABLE_LOGRAGE"] == "1") +if ENV["ENABLE_LOGSTASH_LOGGER"] == "1" require "lograge" Rails.application.config.after_initialize do @@ -144,29 +143,25 @@ if (Rails.env.production? && SiteSetting.logging_provider == "lograge") || end end - if ENV["ENABLE_LOGSTASH_LOGGER"] == "1" - config.lograge.formatter = Lograge::Formatters::Logstash.new + config.lograge.formatter = Lograge::Formatters::Logstash.new - require "discourse_logstash_logger" + require "discourse_logstash_logger" - config.lograge.logger = - DiscourseLogstashLogger.logger( - logdev: Rails.root.join("log", "#{Rails.env}.log"), - type: :rails, - customize_event: - lambda do |event| - event["database"] = RailsMultisite::ConnectionManagement.current_db - end, - ) - - # Stop broadcasting to Rails' default logger - Rails.logger.stop_broadcasting_to( - Rails.logger.broadcasts.find { |logger| logger.is_a?(ActiveSupport::Logger) }, + config.lograge.logger = + DiscourseLogstashLogger.logger( + logdev: Rails.root.join("log", "#{Rails.env}.log"), + type: :rails, + customize_event: + lambda { |event| event["database"] = RailsMultisite::ConnectionManagement.current_db }, ) - Logster.logger.subscribe do |severity, message, progname, opts, &block| - config.lograge.logger.add_with_opts(severity, message, progname, opts, &block) - end + # Stop broadcasting to Rails' default logger + Rails.logger.stop_broadcasting_to( + Rails.logger.broadcasts.find { |logger| logger.is_a?(ActiveSupport::Logger) }, + ) + + Logster.logger.subscribe do |severity, message, progname, opts, &block| + config.lograge.logger.add_with_opts(severity, message, progname, opts, &block) end end end diff --git a/config/site_settings.yml b/config/site_settings.yml index f4ee7c1481e..464b1378ee7 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -2346,13 +2346,6 @@ developer: bypass_wizard_check: default: false hidden: true - logging_provider: - hidden: true - default: "default" - type: "list" - choices: - - "default" - - "lograge" bootstrap_error_pages: hidden: true default: false diff --git a/db/migrate/20240709015048_remove_logging_provider_site_setting.rb b/db/migrate/20240709015048_remove_logging_provider_site_setting.rb new file mode 100644 index 00000000000..95d64d405b1 --- /dev/null +++ b/db/migrate/20240709015048_remove_logging_provider_site_setting.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class RemoveLoggingProviderSiteSetting < ActiveRecord::Migration[7.1] + def up + execute "DELETE FROM site_settings WHERE name = 'logging_provider'" + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end