Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid health check logs on default log file #302

Closed
gugaiz opened this issue Oct 24, 2024 · 1 comment
Closed

Avoid health check logs on default log file #302

gugaiz opened this issue Oct 24, 2024 · 1 comment

Comments

@gugaiz
Copy link

gugaiz commented Oct 24, 2024

Environment

  • Ruby Version: 3.2.2
  • Semantic logger version: 4.16
  • Application/framework names and versions: Rails 6.1.7.4, Puma: 5.6.9
  • Rails Semantic Logger Version: 4.17.0.

Description

I have created a file named: config/initializers/semantic_logger.rb with the following config inside

Rails.application.configure do
  #config.rails_semantic_logger.add_file_appender = false
  config.semantic_logger.add_appender(
    file_name: "#{Rails.root}/log/#{Rails.env}.log",
    formatter: :default,
    filter: -> log {
      log.name != 'HealthCheck::HealthCheckController'
    }
  )
end

but after this change, I am still seeing health_check logs like the one below on the log/development.log file

2024-10-23 13:28:50.021360 I [182010:puma srv tp 001] {client_ip: ::1} (15.3ms) HealthCheck::HealthCheckController -- Completed #index -- { :action => "index", :allocations => 59294, :controller => "HealthCheck::HealthCheckController", :db_runtime => 0.2, :format => "TEXT", :method => "GET", :path => "/health_check", :status => 200, :status_message => "OK", :view_runtime => 2.78 }

I also tried adding config.rails_semantic_logger.add_file_appender = false before adding the appender but it didn't make a difference

Expected Behavior

  • I would expect to filter health_check logs on the default log file, but it is not working
  • If I create an appender on a different path, the filter works fine, but I would like to skip health_check logs on the default file.
@gugaiz
Copy link
Author

gugaiz commented Oct 28, 2024

I tried adding

config.rails_semantic_logger.filter = Proc.new { |log| log.name != 'HealthCheck::HealthCheckController'}

but didn't work either

@gugaiz gugaiz closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant