Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Custom Logger

Jay edited this page Apr 18, 2016 · 4 revisions

Since, v1.7.0, PayPal PHP SDK supports custom logger injection. This allows developers to extend their own logging implementation to PHP SDK.

Steps to Implement custom logger

pushHandler(new Monolog\Handler\StreamHandler("mail.log")); return $logger; } } ``` - Set `log.AdapterFactory` settings in your `$apiContext->setConfig()` method as shown below: ```php $apiContext->setConfig( array( ... 'log.LogEnabled' => true, 'log.FileName' => '../PayPal.log', 'log.LogLevel' => 'DEBUG', 'log.AdapterFactory' => 'MonologLogFactory' // Factory class implementing \PayPal\Log\PayPalLogFactory ... ) ); ``` - Thats it. Run some samples, and see the `mail.log` file getting created and logged with debug messages. - NOTE: be sure to add `monolog\monolog` as a dependency in composer for this example.