PHP code example of epii / log
1. Go to this page and download the library: Download epii/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/ */
epii / log example snippets
//初始化(全局有效)
use epii\log\EpiiLog;
EpiiLog::setDebug(true); //开启debug 参数 true为开启 false为关闭
EpiiLog::setLevel(EpiiLog::LEVEL_NOTICE); //设置级别 该级别下不报错
EpiiLog::setDriver((new \epii\log\driver\EchoDriver()); //选择Echo模式
//打印日志
EpiiLog::error($object); //支持不同的日志级别 这里仅以error示例
//初始化(全局有效)
use epii\log\EpiiLog;
EpiiLog::setDebug(true); //开启debug 参数 true为开启 false为关闭
EpiiLog::setLevel(EpiiLog::LEVEL_NOTICE); //设置级别 该级别下不报错
EpiiLog::setDriver((new \epii\log\driver\FileDriver('./logs/')); //选择File模式,FileDriver初始化中传入需要存放日志的目录
//写入日志
EpiiLog::error($object); //支持不同的日志级别 这里仅以error示例
//初始化(全局有效)
use epii\log\EpiiLog;
EpiiLog::setDebug(true); //开启debug 参数 true为开启 false为关闭
EpiiLog::setLevel(EpiiLog::LEVEL_NOTICE); //设置级别 该级别下不报错
EpiiLog::setDriver((new \epii\log\driver\ApiDriver('http://api.log.wszx.cc/?app=getlog@get',array $data)); //选择Api模式,第一个参数为要远端存储所需要请求的url地址;第二个参数为需要传输的数据(array)
//发起请求
EpiiLog::error($object); //支持不同的日志级别 这里仅以error示例
EpiiLog::warn($object);
EpiiLog::info($object);
EpiiLog::notice($object);
EpiiLog::debug($object);
EpiiLog::error($object);