如何禁用Laravel 5日志文件? [英] How to disable Laravel 5 log file?

查看:426
本文介绍了如何禁用Laravel 5日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Laravel 5 网站正在具有1 GB磁盘空间的共享主机中工作.但是现在我有大约100 MB的日志文件.如何在 Laravel 5 禁用日志文件?

My Laravel 5 website is working in a shared host with 1 GB disk space. But now I have about 100 MB log file. How I can disable log file in Laravel 5 ?

推荐答案

为了完全禁用日志记录,您需要覆盖Laravel设置的默认日志处理程序.您可以使用

In order to completely disable logging you'll need to overwrite the default log handlers that are set by Laravel. You can easily do this with

$nullLogger = new NullHandler();
\Log::getMonolog()->setHandlers(array($nullLogger));

您需要在处理请求之前尽早致电,例如您可以在 bootstrap/app.php 中进行此操作:

You need to call as early as possible, before request is processed, e.g. you could do that in your bootstrap/app.php:

$app->configureMonologUsing(function($monolog) {
  $nullLogger = new \Monolog\Handler\NullHandler();
  $monolog->setHandlers(array($nullLogger));
});

return $app;

这篇关于如何禁用Laravel 5日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆