OBS PHP SDK provides the logging function based on the monolog log library. You can call ObsClient->initLog to enable and configure logging. Sample code is as follows:
$obsClient -> initLog ([ 'FilePath' => './logs', // Set the log folder. 'FileName' => 'eSDK-OBS-PHP.log', // Set the name for the log file. 'MaxFiles' => 10, // Set the maximum number of log files that can be retained. 'Level' => WARN // Set the log level. ]);
The SDK log format is: Log time|log level|number of code line of the printed log|log content The following are example logs:
[2017-11-17 11:46:24][INFO][SendRequestTrait.php:376]: enter method createBucketAsync... [2017-11-17 11:46:24][INFO][SendRequestTrait.php:525]: http request cost 97 ms [2017-11-17 11:46:24][INFO][SendRequestTrait.php:538]: obsclient cost 155 ms to execute createBucketAsync
When current logs cannot be used to troubleshoot system faults, you can change the log level to obtain more information. SDK defines four types of integer constant corresponding to different log levels. You can obtain the most information in DEBUG logs and the least information in ERROR logs.
Log level description: