Skip to content

Exception Not Logged With Object (ARCH7159)

Key php.logging.exception-not-logged · Severity warning · Category logging

Logging only a text message inside a catch drops the exception object and stack trace, losing context that is critical for diagnosis.

<?php
try {
$this->mailer->send($message);
} catch (TransportException $e) {
$this->logger->error('Email send failed');
}
<?php
try {
$this->mailer->send($message);
} catch (TransportException $e) {
$this->logger->error('Email send failed', ['exception' => $e]);
}

Add the exception object to the log context under the exception key.