-
-
Notifications
You must be signed in to change notification settings - Fork 240
Open
Description
Hi,
I use a service definition config like this one:
return static function (ContainerConfigurator $container) {
$services = $container->services();
$services
->defaults()
->autowire()
->autoconfigure()
->tag('monolog.logger', ['channel' => 'defaultchannel'])
;
$services
->set(\MyService::class)
->tag('monolog.logger', ['channel' => 'specificchannel'])
;
}
So I'd like to define a default channel in the service defaults, but override this default for some services. But in reality MyService will always use the defaultchannel
and never the specificchannel
. This is because
- Symfony adds both tags to MyService, but the one from defaults last deliberately (in AbstractServiceConfigurator)
- MonologBundle iterates over all tags in order, and modifies services for each iteration, which means that the last tag will win (in LoggerChannelPass)
Now I'm unsure where the problem is located. Is my reasoning about defaults and specific overrides correct? Is this in theory the right way to do (if not, what is a better/working/official solution?)? Or is this a possible improvement for the bundle?
Thank you in advance for insights 🙂
Metadata
Metadata
Assignees
Labels
No labels