You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When logger is of type LogStashLogger::Formatter it doesn't need to print the log_tags because it is already included in the event hash.
So the current self.build_default_logger(opts) function will create a logger_class with ::Logger so the config.log_tags will not be prepended to every message. But if you think about it, that's the wrong behavior for when setting the format to Logger::Formatter or Logger::SimpleFormatter, because you expect that the tags should show here.
So the solution could be, to check if the formatter's ancestors include LogStashLogger::Formatter::Base, and if it doesn't we can pass the logger into ActiveSupport::TaggedLogging.new(logger). Like so:
Tagged logging isn't something that exists in Ruby's standard library. It's available in ActiveSupport, and LogStashLogger has a compatible implementation. So naturally Logger::Formatter, which is in the Ruby standard library, doesn't include log tags in the output.
If you are using ActiveSupport, you can try the following:
When you use the
formatter: ::Logger::Formatter
the output does not prepend theconfig.log_tags
.What's interesting is the
LogStashLogger::Formatter::*
all include"tags":["127.0.0.1"]
in the output.The text was updated successfully, but these errors were encountered: