Skip to content

Commit 1abdc24

Browse files
committed
STORY-18706: Update README
1 parent aa7e7fd commit 1abdc24

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ end
4343

4444
contextual_logger = ApplicationLogger.new(STDOUT)
4545
```
46+
### Initialization of an ActiveSupport::BroadcastLogger
47+
ActiveSupport 7.1 added a BroadcastLogger class. In order to broadcast logs including context, you need to `extend` the BroadcastLogger instance with a separate mixin:
48+
```ruby
49+
logger = Logger.new(STDOUT).extend(ContextualLogger::LoggerMixin)
50+
other_logger = Logger.new(other_log_stream).extend(ContextualLogger::LoggerMixin)
51+
broadcast_logger = ActiveSupport::BroadcastLogger.new(logger, console_logger).extend(ContextualLogger::BroadcastLoggerMixin)
52+
```
53+
All loggers being passed to the BroadcastLogger must also be contextual loggers.
54+
4655
## Ways to Set Context
4756
Context may be provided any of 3 ways. Typically, all 3 will be used together.
4857

0 commit comments

Comments
 (0)