MongoDB\add_logger()
For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt
MongoDB\add_logger()
New in version 1.17
Definition
Registers a PSR logger to receive log messages from the extension.
function add_logger(Psr\Log\LoggerInterface $logger): void
Parameters
$logger : Psr\Log\LoggerInterface
A logger to register.
If the logger is already registered, the method will have no effect.
Behavior
This function allows the application to register one or more [Psr\Log\LoggerInterface](https://www.php-fig.org/psr/psr-3/#3-psrlogloggerinterface objects to receive log messages from libmongoc and the extension. Each registered logger will receive messages for all clients.
Messages originating from the extension will have their log level translated to an equivalent PSR log level.
Log messages also include a domain string that identifies the driver component that emitted the log message. This value is provided to the PSR logger via the {{domain}} key of the context array.
Errors/Exceptions
[MongoDB\Exception\InvalidArgumentException](https://www.mongodb.com/docs/php-library/current/reference/exception-classes.md#mongodb-phpclass-phpclass.MongoDB-Exception-InvalidArgumentException for errors related to the parsing of parameters or options.
See Also
-
[
MongoDB\remove_logger()](https://www.mongodb.com/docs/php-library/current/reference/function/remove_logger.md#mongodb-phpmethod-phpmethod.MongoDB-remove_logger--
