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

File appender ignoring formatter? #181

Open
mhellsten-ml opened this issue Nov 15, 2022 · 1 comment
Open

File appender ignoring formatter? #181

mhellsten-ml opened this issue Nov 15, 2022 · 1 comment

Comments

@mhellsten-ml
Copy link

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)
    in development.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!

@mhellsten-ml
Copy link
Author

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?

@reidmorrison reidmorrison transferred this issue from reidmorrison/semantic_logger Mar 26, 2023
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