<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes?</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.3.10</td>
</tr>
</tbody>
</table>
<p dir="auto">Given</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="use Psr\Log\LoggerInterface;
class Some {
    public function __construct(LoggerInterface $logger) { }
}"><pre class="notranslate"><span class="pl-k">use</span> <span class="pl-v">Psr</span>\<span class="pl-v">Log</span>\<span class="pl-v">LoggerInterface</span>;
<span class="pl-k">class</span> <span class="pl-v">Some</span> {
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">__construct</span>(<span class="pl-smi"><span class="pl-smi">LoggerInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>logger</span>) { }
}</pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="services:
    _defaults: { autowire: true, autoconfigure: true, public: false }
    Ns\Some:
        tags: [ { name: monolog.logger, channel: my_channel } ]"><pre class="notranslate"><span class="pl-ent">services</span>:
    <span class="pl-ent">_defaults</span>: <span class="pl-s">{ autowire: true, autoconfigure: true, public: false }</span>
    <span class="pl-ent">Ns\Some</span>:
        <span class="pl-ent">tags</span>: <span class="pl-s">[ { name: monolog.logger, channel: my_channel } ]</span></pre></div>
<p dir="auto">I get the <code class="notranslate">app</code> channel logger. However if i add</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Ns\Some:
    arguments: { '$logger' : '@logger' }
    tags: [ { name: monolog.logger, channel: my_channel } ]"><pre class="notranslate"><span class="pl-ent">Ns\Some</span>:
    <span class="pl-ent">arguments</span>: <span class="pl-s">{ '$logger' : '@logger' }</span>
    <span class="pl-ent">tags</span>: <span class="pl-s">[ { name: monolog.logger, channel: my_channel } ]</span></pre></div>
<p dir="auto">I get the <code class="notranslate">my_channel</code> logger. Can we improve that?</p>
<p dir="auto">It looks like the MonologBundle has a priority too high, and runs too early, applying channel tagging before that the services have been autowired.</p>
<p dir="auto">In my case :</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false
        tags:
            - { name: monolog.logger, channel: technical }

    AppBundle\Manager\:
        resource: '../../../src/AppBundle/Manager'"><pre class="notranslate"><span class="pl-ent">services</span>:
    <span class="pl-ent">_defaults</span>:
        <span class="pl-ent">autowire</span>: <span class="pl-c1">true</span>
        <span class="pl-ent">autoconfigure</span>: <span class="pl-c1">true</span>
        <span class="pl-ent">public</span>: <span class="pl-c1">false</span>
        <span class="pl-ent">tags</span>:
            - <span class="pl-s">{ name: monolog.logger, channel: technical }</span>

    <span class="pl-ent">AppBundle\Manager\</span>:
        <span class="pl-ent">resource</span>: <span class="pl-s"><span class="pl-pds">'</span>../../../src/AppBundle/Manager<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">My loggers inside my managers are not handled with <code class="notranslate">technical</code> channel.</p>
<p dir="auto">But if i change the service definitions by :</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    AppBundle\Manager\:
        resource: '../../../src/AppBundle/Manager'
        arguments:
            - '@logger'"><pre class="notranslate">    <span class="pl-ent">AppBundle\Manager\</span>:
        <span class="pl-ent">resource</span>: <span class="pl-s"><span class="pl-pds">'</span>../../../src/AppBundle/Manager<span class="pl-pds">'</span></span>
        <span class="pl-ent">arguments</span>:
            - <span class="pl-s"><span class="pl-pds">'</span>@logger<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">it works.</p>
<p dir="auto">So it looks like MonologBundle find the tag, but there is no logger inside the service to be overridden. Then, the autowiring will run and will put the default logger inside my services, ignoring the tagging.</p>