diff --git a/php/libraries/Module.class.inc b/php/libraries/Module.class.inc index 0f85f43a16f..a85231ed359 100644 --- a/php/libraries/Module.class.inc +++ b/php/libraries/Module.class.inc @@ -169,10 +169,6 @@ abstract class Module extends \LORIS\Router\PrefixRouter */ public function __construct(string $name, string $moduledir) { - $config = \NDB_Factory::singleton()->config(); - $loglevel = $config->getLogSettings()->getRequestLogLevel(); - - $this->logger = new \LORIS\Log\ErrorLogLogger($loglevel); parent::__construct( new \ArrayIterator( [ diff --git a/src/Router/BaseRouter.php b/src/Router/BaseRouter.php index 358ad5fe988..e598c3009aa 100644 --- a/src/Router/BaseRouter.php +++ b/src/Router/BaseRouter.php @@ -94,15 +94,12 @@ public function handle(ServerRequestInterface $request) : ResponseInterface $factory = \NDB_Factory::singleton(); $ehandler = new \LORIS\Middleware\ExceptionHandlingMiddleware(); - $exceptionloglevel = $this->lorisinstance->getConfiguration() - ->getLogSettings() - ->getExceptionLogLevel(); + $logSettings = $this->lorisinstance->getConfiguration()->getLogSettings(); + $exceptionloglevel = $logSettings->getExceptionLogLevel(); if ($exceptionloglevel != "none") { $ehandler->setLogger( - new \LORIS\Log\ErrorLogLogger( - $factory->config()->getLogSettings()->getExceptionLogLevel() - ) + new \LORIS\Log\ErrorLogLogger($exceptionloglevel) ); } else { $ehandler->setLogger(new \PSR\Log\NullLogger); @@ -120,7 +117,17 @@ public function handle(ServerRequestInterface $request) : ResponseInterface $factory->setBaseURL($baseurl); - $module = \Module::factory($modulename); + $module = \Module::factory($modulename); + + $requestloglevel = $logSettings->getRequestLogLevel(); + if ($requestloglevel != "none") { + $module->setLogger( + new \LORIS\Log\ErrorLogLogger($requestloglevel) + ); + } else { + $module->setLogger(new \PSR\Log\NullLogger); + } + $mr = new ModuleRouter($module); $request = $request->withURI($suburi); return $ehandler->process($request, $mr);