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这个容器,点进去, 我们来到了 点击这个跳 ...
随机推荐
- java入门 第一季3
运算符:算术运算符,赋值运算符,比较运算符,逻辑运算符,条件运算符 1. 算术运算符: 自增和自减只能用于操作变量,不能直接用于操作数值和常量 % 求余数 2. 赋值运算符 = 赋值运算符为变量或常 ...
- codeforces 518B. Tanya and Postcard 解题报告
题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就 ...
- linux下QT Creator常见错误及解决办法
最近因为在做一个关于linux下计算机取证的小项目,需要写一个图形界面,所以想到了用QT来写,选用了linux下的集成开发环境QT Creator5.5.1,但刚刚安装好,竟然连一个"hel ...
- filter 简介
概述 filter() 方法使用指定的函数测试所有元素,并创建一个包含所有通过测试的元素的新数组. 语法 var new_arrary = arr.filter(callback[, thisArg] ...
- [Android Pro] 使用apktool工具遇到could not decode arsc file的解决办法
转:http://www.cnblogs.com/sage-blog/p/4323049.html 最近使用APKtool工具反编译APK老是提示不成功,错误如下: Exception in thre ...
- YAML-初识
YAML简介 YAML-what? YAML Ain't Markup Language 和GNU一样,YAML是一个递归着说"不"的名字.不同的是,GNU对UNIX说不,YAML ...
- idea 用maven骨架生成项目速度慢的问题
使用mvn archetype:generate命令时,加上-DarchetypeCatalog=local archetypeCatalog=local
- springmvc中RedirectAttributes的作用
RedirectAttributes在重定向的时候可以传参,不能跨站传参,因为参数是保存在服务器端
- Django搭建简易博客
Django简易博客,主要实现了以下功能 连接数据库 创建超级用户与后台管理 利用django-admin-bootstrap美化界面 template,view与动态URL 多说评论功能 Markd ...
- Loadrunner11.0 录制手机App脚本的方法
使用Loadrunner录制手机终端App脚本 1. 说明 目前手机APP上的功能日益丰富,对手机应用功能的性能测试需求也越来越多.公司比较抠门没有花钱买Loadrunner,可怜我们工作中一直用的破 ...