Laravel-错误调试与记录日志

Laravel-错误调试与记录日志

标签(空格分隔): php


错误调试

配置

修改/config/app.php

'debug' => env('APP_DEBUG', true),

开启debug为true 当代码有错误时会有提示,不然的话 [Whoops, looks like something went wrong.] 一头雾水不知道什么意思

效果

记录日志

配置

修改/config/app.php

/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/

'log' => env('APP_LOG', 'single'),

'log_level' => env('APP_LOG_LEVEL', 'debug'),

有 Available Settings: "single", "daily", "syslog", "errorlog" 这几个选项

操作

该日志记录器提供了RFC 5424中定义的八种日志级别:emergency、alert、critical、error、warning、notice、info 和 debug

Log::emergency($error);
Log::alert($error);
Log::critical($error);
Log::error($error);
Log::warning($error);
Log::notice($error);
Log::info($error);
Log::debug($error);

----------------------------

也可以通过辅助函数
info($error) info级别
logger($error) debug级别
posted @ 2018-08-21 15:45  TaylorSWMM  阅读(1045)  评论(1编辑  收藏  举报