1. Go to this page and download the library: Download apeipo/xl-util 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/ */
use XLUtil\XLLog;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$handler = (new StreamHandler("./test.log", Logger::DEBUG));
$logger = new Logger('test', [$handler]);
XLLog::setLogger($logger);
#设置全局logid, 这个逻辑可以放在web框架的入口,生成logid的方式请自行修改
XLLog::setLogid("LOG_ID", time());
XLLog::addNoticeKV("file", __FILE__); #增加key,但是不打印
XLLog::addNoticeKV("method", "test");
XLLog::warning("This is in test");
XLLog::flush("RequestFinish"); #打印所有的kv并清空
####output
[2017-07-10 13:22:56] test.WARNING: This is in test {"LOG_ID":1499692976} []
[2017-07-10 13:22:56] test.NOTICE: RequestDone {"file":"testMonologDecorator.php","method":"test","LOG_ID":1499692976} []
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.