rails_semantic_logger
rails_semantic_logger copied to clipboard
File appender ignoring formatter?
Environment
- Ruby Version: 2.5.8
- Semantic Logger Version: 4.12
- Application/framework: Rails 5.2.4
- Rails Semantic Logger Version: 4.11
- Rails configuration:
config.semantic_logger.add_appender(file_name: "log/#{Rails.env}.json", formatter: :json)
indevelopment.rb
Expected Behavior
A log/development.json file with json-formatted output
Actual Behavior
The log/development.json file appears and gets content, but it's the default color formatter, not json. What could I be doing wrong?
Thank you!
I was able to reproduce this on Rails 6.1.7 with Ruby 2.5.8. and Rails 6.1.7 with Ruby 2.6.6 too. If I add the appender using config.semantic_logger.add_appender
as indicated above in application.rb
or environments/<environment>.rb
(as suggested by the documentation, if I understand correctly), the appender formatter gets clobbered somehow. If, instead, I add it using SemanticLogger.add_appender(file_name: "log/#{Rails.env}.json", formatter: :json)
in an initializer, it seems to work as expected.
Any thoughts why that's happening, and does it make sense to leave it like I have it now?