rails_semantic_logger
rails_semantic_logger copied to clipboard
Avoid health check logs on default log file
trafficstars
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
I also tried adding:
config.rails_semantic_logger.filter = Proc.new { |log| log.name != 'HealthCheck::HealthCheckController'}
but after these changes, 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.