Skip to content

Commit 2d472f4

Browse files
FIX Don't log to the error handler (#11523)
1 parent 754ac17 commit 2d472f4

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

_config/logging.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ SilverStripe\Core\Injector\Injector:
1616
pushDefaultLogger: [ pushLogger, [ '%$Psr\Log\LoggerInterface' ] ]
1717
pushErrorHandler: [ pushLogger, [ '%$Psr\Log\LoggerInterface.errorhandler' ] ]
1818

19-
# Default implementation for use as a standard logger. Up to developers to attach their own
20-
# handlers
19+
# Default implementation for use as a standard logger. Used for logging custom messages.
20+
# Projects should attach log handlers to this logging service.
2121
Psr\Log\LoggerInterface:
2222
type: singleton
2323
class: Monolog\Logger
2424
constructor:
2525
- "error-log"
26-
# Core error handling
26+
# Core error handling - only uncaught exceptions and PHP errors should be caught by this handler.
27+
# This handler displays those errors in the browser and CLI.
28+
# Projects should not attach log handlers to this error handler service.
2729
Psr\Log\LoggerInterface.errorhandler:
2830
type: singleton
2931
class: Monolog\Logger

src/Security/Member.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ public function onBeforeWrite()
808808
$email->send();
809809
} catch (TransportExceptionInterface | RfcComplianceException $e) {
810810
/** @var LoggerInterface $logger */
811-
$logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
811+
$logger = Injector::inst()->get(LoggerInterface::class);
812812
$logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}");
813813
}
814814
}

src/Security/MemberAuthenticator/LostPasswordHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ protected function sendEmail($member, $token)
256256
return true;
257257
} catch (TransportExceptionInterface | RfcComplianceException $e) {
258258
/** @var LoggerInterface $logger */
259-
$logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
259+
$logger = Injector::inst()->get(LoggerInterface::class);
260260
$logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}");
261261
return false;
262262
}

0 commit comments

Comments
 (0)