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错误与日志处理的更多相关文章

  1. laravel中的错误与日志

    日志 laravel中的日志是基于monolog而封装的.laravel在它上面做了几个事情: 把monolog中的addInfo等函数简化成为了info这样的函数 增加了useFiles和useDa ...

  2. Laravel中的日志与上传

    PHP中的框架众多,我自己就接触了好几个.大学那会啥也不懂啥也不会,拿了一个ThinkPHP学了.也许有好多人吐槽TP,但是个人感觉不能说哪个框架好,哪个框架不好,再不好的框架你能把源码读上一遍,框架 ...

  3. 基于sentry的前端错误监控日志系统(部署sentry服务器/前端项目部署)-让前端最快的定位到生产问题

    背景 在这越来越发达的网络时代,web应用也是越来越复杂,尤其是前端的开发,也是越来越受重视. 所以在我们前端开发完成后,会有一些列的web应用的上线验证,如自测.QA测试.code review 等 ...

  4. laravel 错误提示Fatal Error: Class 'Pheanstalk\Pheanstalk' not found

    本地环境版本: composer -V Composer version -- ::10 php artisan -V Laravel Framework 5.6.39 错误提示: Fatal Err ...

  5. laravel错误1071 Specified key was too long; max key length is 1000 bytes

    Laravel 5.5 环境,php artisan migrate 之后,出现错误如题. 检查了一下,代码是这样的: $table->increments('id'); $table-> ...

  6. laravel支持的日志写入模式和日志严重程度级别:

    四种日志写入模式: single:单一的 daily:日常的 syslog:系统记录 errorlog:错误日志 Monolog 识别以下严重程度的级别, 从低到高为: debug. info.not ...

  7. 记一次Laravel定时任务导致日志没有写入权限的坑

    问题:用laravel开发定时任务时,发生了日志没有写入权限导致项目打不开的问题 原因:linux的添加定时任务时默认是当前登录用户,我定时任务会生成日志 crontab: kernel: 生成日志的 ...

  8. 错误Log日志的收集

    1.在Application里面初始化 AppCrashHandler.getInstance(this); 2.创建一个类 package com.lvshandian.partylive.util ...

  9. 分析laravel的核心日志类

    首先是容器 log对应的是application这个容器 首先我们查看如何获取这个日志类,我们来到\storage\app.php中找到application这个容器,点进去, 我们来到了 点击这个跳 ...

随机推荐

  1. MFC Initinstance中DoModal()返回-1

    新建一个基于对话框的MFC应用程序,在App的Initinstance中调用对话框DoModal()来显示对话框,这是框架的内容,应用程序框架生成的全部是正常的. 当把我对话框的资源文件提取到一个资源 ...

  2. 关于C语言中的转义字符

    1.转义字符的分类 1. 1一般转义字符 这种转义字符,虽然在形式上由两个字符组成,但只代表一个字符.常用的一般转义字符为: \a     \n     \t     \v     \b     \r ...

  3. div+css进度条

    效果图: 进度条代码: <style type="text/css"> 红色:background-color:f05153:border:1px solid #f05 ...

  4. 【leetcode】Search for a Range(middle)

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  5. 【linux】学习2

    鸟哥那本书的第6章 文件权限: ^                ^     ^      ^        ^              ^                 ^ 1         ...

  6. 网站配置好了,在本地能登录系统,但是挂在IIS上就无法登录了,提示数据库连接错误

    我用的VS2010开发的网站,但是挂在本机的IIS上的时候就无法登录了,提示错误如下:

  7. Java容器题库

    一.    填空题 Java集合框架提供了一套性能优良.使用方便的接口和类,包括Collection和Map两大类,它们都位于  java.util  包中 队列和堆栈有些相似,不同之处在于栈是先进后 ...

  8. mac os 下打开FTP服务器

    mac下一般用smb服务来进行远程文件访问,但要用FTP的话,高版本的mac os默认关掉了,可以用如下命令打开: sudo -s launchctl load -w /System/Library/ ...

  9. 2048控制台程序:一份帝国理工C++作业

    #include <fstream> #include <vector> #include <iostream> #include <string> u ...

  10. August 7th 2016, Week 33rd Sunday

    Knowing yourself is the height of wisdom. 了解自己就是大智慧. Two-day holiday, even I didn't have enought tim ...