您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-日志-使用
发布时间:2022-01-29 16:03:53编辑:雪饮阅读()
webman使用 monolog/monolog 处理日志。
使用實例\app\controller\Foo.php控制器:
<?php
namespace app\controller;
use support\Request;
use support\View;
use support\Log;
class Foo
{
/**
* 该方法会在请求前调用
*/
public function beforeAction(Request $request)
{
echo 'beforeAction';
// 若果想终止执行Action就直接返回Response对象,不想终止则无需return
// return response('终止执行Action');
}
/**
* 该方法会在请求后调用
*/
public function afterAction(Request $request, $response)
{
}
public function index0(){
throw new \Exception("異常出現了!");
}
public function index(Request $request)
{
Log::info('log test');
return response('hello index');
}
public function login(Request $request)
{
$session = $request->session();
$session->set('userinfo', ["user_name"=>"kasumi"]);
return response('login success');
}
public function loginPage(Request $request){
return response("this is loginPage \n");
}
}
先清空下咱們當前產生的日志,比如今天產生的日志先清空了:
[root@localhost ~]# echo "" > /www/wwwroot/webman/webman/runtime/logs/webman-2022-01-29.log
[root@localhost ~]# cat /www/wwwroot/webman/webman/runtime/logs/webman-2022-01-29.log
爲什麽要清理這個路徑?分析config/log.php得知
然後實例被請求后再次查看日志即可看到剛才生成的日志:
[root@localhost ~]# elinks http://127.0.0.1:8787/blog/index --dump
hello index
[root@localhost ~]# cat /www/wwwroot/webman/webman/runtime/logs/webman-2022-01-29.log
[2022-01-29 15:54:56] default.INFO: log test [] []
关键字词:webman,日志,使用
相关文章
- webman-session管理-配置文件-更換session驅動為redis
- webman-session管理-配置文件-redis集群搭建(單宿主機
- webman-session管理-配置文件-更換session驅動為redis
- webman-session管理-助手函数session()-給session賦值
- webman-session管理-助手函数session()-獲取某個值
- webman-session管理-助手函数session()-session實例獲
- webman-session管理-判断对应session数据是否存在
- webman-session管理-删除所有session数据
- webman-session管理-删除session数据
- webman-session管理-存儲session(set與put)