Docs Menu

Docs HomePHP Library Manual

MongoDB\add_logger()

On this page

  • Definition
  • Parameters
  • Behavior
  • Errors/Exceptions
  • See Also

New in version 1.17.

MongoDB\add_logger()

Registers a PSR logger to receive log messages from the driver.

function add_logger(Psr\Log\LoggerInterface $logger): void
$logger : Psr\Log\LoggerInterface

A logger to register.

If the logger is already registered, the method will have no effect.

This function allows the application to register one or more Psr\Log\LoggerInterface objects to receive log messages from libmongoc and the driver. 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. For performance reasons, trace-level messages from the extension are not forwarded to PSR loggers. The extension's mongodb.debug INI configuration must be used to collect trace-level logs.

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.

MongoDB\Exception\InvalidArgumentException for errors related to the parsing of parameters or options.

← Functions