PHP code example of ydg / monolog-aliyun-log
1. Go to this page and download the library: Download ydg/monolog-aliyun-log library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ydg / monolog-aliyun-log example snippets
use Monolog\Logger;
use Hdk\MonologAliyunLog\AliyunLogHelper;
$config = [
'endpoint' => 'your endpoint',
'accessKeyId' => 'your accessKeyId',
'accessKey' => 'your accessKey',
'project' => 'your project',
'logstore' => 'your logstore',
];
$log = new Logger('name');
$log->pushHandler(AliyunLogHelper::getLogHandler(AliyunLogHelper::getLogClient($config), $config));
// add records to the log
$log->warning('Foo');
$log->error('Bar');