-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Logger Tags don't get broadcasted to another Tagged Logger #43291
Comments
In order to make it work I apply a monkey patch on my application: module TaggedBroadcast
extend ActiveSupport::Concern
class_methods do
def broadcast(logger)
super(logger).tap do |broadcast_logger_class|
broadcast_logger_class.define_method(:tagged) do |*tags, &block|
if logger.respond_to?(:tagged)
logger.tagged(*tags) do
if defined?(super)
super(*tags, &block)
else
block.call(self)
end
end
else
if defined?(super)
super(*tags, &block)
else
block.call(self)
end
end
end
end
end
end
end
ActiveSupport::Logger.prepend(TaggedBroadcast) I can submit a PR for this fix in |
We have a test to make sure this works
I think you need to investigate why your setup is not behaving in the same way as the test. |
Cool, thanks! |
I'm using
ActiveSupport::Logger.broadcast
to broadcast logging to multiple loggers.For example STDOUT, File in
log/
folder and anotherRemoteSysLogger
Also I'm using
ActiveSupport::TaggedLogging
to configure tags withmiddleware
on the config file:But this log tags don't get broadcasted to the other logs.
I don't know if there something that I'm configuring wrong.
Steps to reproduce
Add on
development.rb
Make a GET request to root_path '/'
Expected behavior
I expected that
other.log
file had request tags: [:host, :uuid]Actual behavior
However other log didn't include tags
System configuration
Rails version: 6.1
Ruby version: 2.7
The text was updated successfully, but these errors were encountered: