App\Exceptions\Handler class is where all exceptions triggered by your application are logged and then rendered back to the user. We'll dive deeper into this class throughout this documentation.
For logging, Laravel utilizes the
Monolog library, which provides support for a variety of powerful log handlers. Laravel configures several of these handlers for you, allowing you to choose between a single log file, rotating log files, or writing error information to the system log.
Error Detail
The debug option in your config/app.php configuration file determines how much information about an error is actually displayed to the user. By default, this option is set to respect the value of the APP_DEBUG environment variable, which is stored in your .env file.
For local development, you should set the APP_DEBUG environment variable to true. In your production environment, this value should always be false. If the value is set to true in production, you risk exposing sensitive configuration values to your application's end users.
Laravel supports writing log information to single files, daily files, the syslog, and the errorlog. To configure which storage mechanism Laravel uses, you should modify the logoption in your config/app.php configuration file. For example, if you wish to use daily log files instead of a single file, you should set the log value in your app configuration file to daily:
'log' => 'daily'
Maximum Daily Log Files
When using the daily log mode, Laravel will only retain five days of log files by default. If you want to adjust the number of retained files, you may add a log_max_files configuration value to yourapp configuration file:
'log_max_files' => 30
Severity Levels
When using Monolog, log messages may have different levels of severity. By default, Laravel writes all log levels to storage. However, in your production environment, you may wish to configure the minimum severity that should be logged by adding the log_level option to your app.phpconfiguration file.
Once this option has been configured, Laravel will log all levels greater than or equal to the specified severity. For example, a default log_level of error will log error, critical, alert, and emergencymessages:
'log_level' => env('APP_LOG_LEVEL', 'error'),
Monolog recognizes the following severity levels - from least severe to most severe:debug, info, notice, warning, error, critical, alert, emergency.
All exceptions are handled by the App\Exceptions\Handler class. This class contains two methods:report and render. We'll examine each of these methods in detail. The report method is used to log exceptions or send them to an external service like
Bugsnag or
Sentry. By default, the reportmethod simply passes the exception to the base class where the exception is logged. However, you are free to log exceptions however you wish.
Ignoring Exceptions By Type想要忽略的
The $dontReport property of the exception handler contains an array of exception types that will not be logged.
Some exceptions describe HTTP error codes from the server. For example, this may be a "page not found" error (404), an "unauthorized error" (401) or even a developer generated 500 error. In order to generate such a response from anywhere in your application, you may use the abort helper:
abort(404);
abort(403, 'Unauthorized action.');
Custom HTTP Error Pages
For example, if you wish to customize the error page for 404 HTTP status codes, create aresources/views/errors/404.blade.php
The views within this directory should be named to match the HTTP status code they correspond to. The HttpException instance raised by the abort function will be passed to the view as an $exception variable.
emergency, alert, critical, error,warning, notice, info and debug.
By default, Laravel is configured to create a log file for your application in the storage/logs directory. You may write information to the logs using the Log
facade:
Log::emergency($message); Log::alert($message); Log::critical($message); Log::error($message); Log::warning($message); Log::notice($message); Log::info($message); Log::debug($message);
Contextual Information上下文信息
An array of contextual data
- laravel中的错误与日志
日志 laravel中的日志是基于monolog而封装的.laravel在它上面做了几个事情: 把monolog中的addInfo等函数简化成为了info这样的函数 增加了useFiles和useDa ...
- Laravel中的日志与上传
PHP中的框架众多,我自己就接触了好几个.大学那会啥也不懂啥也不会,拿了一个ThinkPHP学了.也许有好多人吐槽TP,但是个人感觉不能说哪个框架好,哪个框架不好,再不好的框架你能把源码读上一遍,框架 ...
- 基于sentry的前端错误监控日志系统(部署sentry服务器/前端项目部署)-让前端最快的定位到生产问题
背景 在这越来越发达的网络时代,web应用也是越来越复杂,尤其是前端的开发,也是越来越受重视. 所以在我们前端开发完成后,会有一些列的web应用的上线验证,如自测.QA测试.code review 等 ...
- laravel 错误提示Fatal Error: Class 'Pheanstalk\Pheanstalk' not found
本地环境版本: composer -V Composer version -- ::10 php artisan -V Laravel Framework 5.6.39 错误提示: Fatal Err ...
- laravel错误1071 Specified key was too long; max key length is 1000 bytes
Laravel 5.5 环境,php artisan migrate 之后,出现错误如题. 检查了一下,代码是这样的: $table->increments('id'); $table-> ...
- laravel支持的日志写入模式和日志严重程度级别:
四种日志写入模式: single:单一的 daily:日常的 syslog:系统记录 errorlog:错误日志 Monolog 识别以下严重程度的级别, 从低到高为: debug. info.not ...
- 记一次Laravel定时任务导致日志没有写入权限的坑
问题:用laravel开发定时任务时,发生了日志没有写入权限导致项目打不开的问题 原因:linux的添加定时任务时默认是当前登录用户,我定时任务会生成日志 crontab: kernel: 生成日志的 ...
- 错误Log日志的收集
1.在Application里面初始化 AppCrashHandler.getInstance(this); 2.创建一个类 package com.lvshandian.partylive.util ...
- 分析laravel的核心日志类
首先是容器 log对应的是application这个容器 首先我们查看如何获取这个日志类,我们来到\storage\app.php中找到application这个容器,点进去, 我们来到了 点击这个跳 ...
随机推荐
- 4.openstack之mitaka搭建glance镜像服务
部署镜像服务 一:安装和配置服务 1.建库建用户 mysql -u root -p CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glance.* T ...
- Effective C++ -----条款41:了解隐式接口和编译期多态
classes和templates都支持接口(interface)和多态(polymorphism). 对classes而言接口是显式的(explicit),以函数签名为中心.多态则是通过virtua ...
- UVALive 4949 Risk(二分网络流、SAP)
n个区域,每个区域有我方军队a[i],a[i]==0的区域表示敌方区域,输入邻接矩阵.问经过一次调兵,使得我方边界处(与敌军区域邻接的区域)士兵的最小值最大.输出该最大值.调兵从i->j仅当a[ ...
- C# 对象操作
//********************************************************************************* //************** ...
- 【leetcode】Gray Code (middle)
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- [Android Pro] http请求中传输base64出现加号变空格的解决办法
reference to : http://blog.csdn.net/jsjwbxzy/article/details/45970231 try { des = URLEncoder.encode( ...
- Mysql手册—SQLStatementSyntax
14.1.1 ALTER DATABASE Syntax,可用于修改数据库字符集和校验规则 查看校验规则可如下: 由于utf8的校验规则都是ci(case insensitive),所以是不区分大小写 ...
- IOS之笑脸app
ios笑脸app实现 import UIKit @IBDesignable class FaceView: UIView { @IBInspectable var lineWidth:CGFloat= ...
- python中获取当前日期在当月是第几天
- 使用drozer连接时提示:Could not find java. Please ensure that it is installed and on your path
在安装drozer后使用 drozer.bat console connect命令提示如下错误(实际上我已经安装了jdk并添加了path) 参考上面的链接已经它的提示解决方法如下: 建立名为 .dro ...