diff --git a/Civi/Core/LogManager.php b/Civi/Core/LogManager.php index 7c50770b385c..82724827756e 100644 --- a/Civi/Core/LogManager.php +++ b/Civi/Core/LogManager.php @@ -38,10 +38,17 @@ public function getLog($channel = 'default') { if (!isset($this->channels[$channel])) { $c = \Civi::container(); $svc = "log." . $channel; - $this->channels[$channel] = $c->has($svc) ? $c->get($svc) : $c->get(self::DEFAULT_LOGGER); - if ($channel !== 'default' && method_exists($this->channels[$channel], 'setChannel')) { - $this->channels[$channel]->setChannel($channel); + if ($c->has($svc)) { + $log = $c->get($svc); } + else { + $log = $c->get(self::DEFAULT_LOGGER);; + if (is_callable([$log, 'setChannel'])) { + $log = clone $log; + $log->setChannel($channel); + } + } + $this->channels[$channel] = $log; } return $this->channels[$channel]; }