Examples / How To

Logging

2min

The PHP-SDK does not specify a dependency on any logging packages, meaning no logging will be performed out of the box. This is an intentional design decision to ensure better integration with existing system.

If you wish to enable logging, you will need to install a package which contains an implementation of Psr\Log\LoggerInterface

While any class which implements the PSR Logger interface is supported, we recommend using the Monolog package, which is already present in many of the major frameworks.

You can install this in your application via composer:

Bash


All services which interact with Klevu's APIs accept a logger instance via their constructor; the only other class which implements logging at time of writing is the RequestBearerTokenProvider , which generates an authentication token for indexing.

Note: If you are integrating into a modern framework, you should implement this via your dependency injection system

PHP


Once implemented, you should start seeing PHP-SDK related logs written to the files specified when creating the Logger.