• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (PHP SDK)
  4. Troubleshooting
  5. Log Analysis

Log Analysis

Log Configuration

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.
]);
NOTE:
  • The logging function is disabled by default. You need to enable it if needed.
  • Use the FilePath parameter to specify the log file path. The path can be an absolute path or a relative path.

Log Format

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

Log Level

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:

  • DEBUG (100): Debugging level. If this level is set, all logs will be printed.
  • INFO (200): Information level. If this level is set, logs at the WARN level and the time consumed for each HTTP/HTTPS request will be printed.
  • WARN (300): Warning level. If this level is set, logs at the ERROR level and some critical events will be printed.
  • ERROR (400): Error level. If this level is set, only error information will be printed.