-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
ActiveSupport::Logger getting "hijacked" by Rails Semantic Logger? #141
Comments
Semantic Logger is as clean as I can make it, but Rails Semantic Logger is nothing but a huge ugly hack to try and get Rails to log in a Semantic (machine readable) way. All of the hackery goes on in here: https://github.com/reidmorrison/rails_semantic_logger/blob/master/lib/rails_semantic_logger/engine.rb If Rails adopted Semantic Logger directly we could just delete Rails Semantic Logger entirely. To fix the stdout logging problems with Rails, we used this hack: https://github.com/reidmorrison/rails_semantic_logger/blob/master/lib/rails_semantic_logger/extensions/rails/server.rb A similar patch for Web Packer would send all log messages to the right place. |
Thank you @reidmorrison. It's hard for me to say, since I'm not deeply familiar with ruby logging or the rails internals. Have you considered submitting a PR to improve the Rails logging? I'm sure the community can benefit from your experience. Perhaps you can also propose integrating SemanticLogger into Rails? I'd be happy to "vouch" for it, FWIW :) Wishing you a happy holiday season and a very happy and healthy 2022. Thanks for contributing your time and energy into open-source. I know it's not easy and not everyone is grateful, but I certainly appreciate your work, and the work of many other open-source contributors. I also try to contribute where I can, on my "own" projects and others like SemanticLogger. If there's anything I can do more to help, please let me know and I'll do my best to help. |
Not sure if it helps, but Rails logs now to Could we modify the following lines, to provide a different format and logger? config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) } |
This is more of a question ... We're not entirely sure what's happening under the hood here, but it feels strange.
Environment
Hope this image explains the issue?
This was initially reported on rails/webpacker#3208
It seems like rails semantic logger "hijacks" ActiveSupport::Logger in some way, and then when Webpacker uses
ActiveSupport::Logger.new(STDOUT)
, it doesn't return an ActiveSupport::Logger instance, and the Rails semantic logger instance being returned does not actually log to stdout ?Expected Behavior
Logs to stdout
Actual Behavior
Does not log to stdout.
The text was updated successfully, but these errors were encountered: