Skip to content

Commit

Permalink
Merge pull request #1088 from DFE-Digital/1812-onboard-services-to-lo…
Browse files Browse the repository at this point in the history
…gitio

[1812] Stop okcomputer logging
  • Loading branch information
johnake authored May 29, 2024
2 parents fa5b511 + 0abfd83 commit f2fd6d2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ group :test do
gem "vcr", "~> 6.2"
gem "webmock", "~> 3.18"
end

group :production do
gem "rails_semantic_logger"
end
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails_semantic_logger (4.14.0)
rack
railties (>= 5.1)
semantic_logger (~> 4.13)
railties (7.1.3.1)
actionpack (= 7.1.3.1)
activesupport (= 7.1.3.1)
Expand Down Expand Up @@ -435,6 +439,8 @@ GEM
rexml
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
semantic_logger (4.15.0)
concurrent-ruby (~> 1.0)
sentry-rails (5.10.0)
railties (>= 5.0)
sentry-ruby (~> 5.10.0)
Expand Down Expand Up @@ -580,6 +586,7 @@ DEPENDENCIES
rack-attack
rails (~> 7.1.3)
rails-erd
rails_semantic_logger
rladr (~> 1.2)
rspec
rspec-rails
Expand Down
5 changes: 5 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@
config.action_mailer.notify_settings = {
api_key: ENV.fetch("GOVUK_NOTIFY_API_KEY"),
}

config.log_level = :info # Or :warn, or :error
config.log_format = :json # For parsing in Logit
config.rails_semantic_logger.add_file_appender = false # Don't log to file
config.active_record.logger = nil # Don't log SQL
end
1 change: 0 additions & 1 deletion config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require_relative "../../lib/ok_computer_checks/zendesk_check"
require_relative "../../lib/ok_computer_checks/notify_check"

OkComputer.logger = Rails.logger
OkComputer.mount_at = "health"

OkComputer::Registry.register "postgresql", OkComputer::ActiveRecordCheck.new
Expand Down
10 changes: 10 additions & 0 deletions config/initializers/semantic_logger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return unless defined?(SemanticLogger)

Rails.application.configure do
config.semantic_logger.application = "" # This is added by logstash from its tags
config.log_tags = [:request_id] # Prepend all log lines with the following tags
end

SemanticLogger.add_appender(io: $stdout, level: Rails.application.config.log_level,
formatter: Rails.application.config.log_format)
Rails.application.config.logger.info('Application logging to STDOUT')

0 comments on commit f2fd6d2

Please sign in to comment.