@@ -18,6 +18,11 @@ the channel).
1818 in the container (use the ``php bin/console debug:container monolog `` command
1919 to see a full list) and those are injected into different services.
2020
21+ .. versionadded :: 4.2
22+
23+ Since Monolog Bundle 3.5 each channel bind into container by type-hinted alias.
24+ More info in the part about :ref: `how to autowire monolog channels <monolog-autowire-channels >`.
25+
2126.. _logging-channel-handler :
2227
2328Switching a Channel to a different Handler
@@ -172,3 +177,26 @@ Symfony automatically registers one service per channel (in this example, the
172177channel ``foo `` creates a service called ``monolog.logger.foo ``). In order to
173178inject this service into others, you must update the service configuration to
174179:ref: `choose the specific service to inject <services-wire-specific-service >`.
180+
181+ .. _monolog-autowire-channels :
182+
183+ How to autowire logger channels
184+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185+
186+ .. versionadded :: 4.2
187+
188+ This feature available since MonologBundle 3.5
189+
190+ Each channel already bind into container by type-hinted alias.
191+ Just use method variables, which follows next naming template ``Psr\Log\LoggerInterface $<channel>Logger ``.
192+ For example, you have ``App\Log\CustomLogger `` service which tagged by ``app `` logger channel
193+ as described in part :ref: `Logging with a custom logging channel <dic_tags-monolog >`.
194+ Now you can remove service configuration at all and change constructor signature:
195+
196+ .. code-block :: diff
197+
198+ - public function __construct(LoggerInterface $logger)
199+ + public function __construct(LoggerInterface $appLogger)
200+ {
201+ $this->logger = $appLogger;
202+ }
0 commit comments