如何在 lumen 中配置日志记录级别

How to configure Logging levels in lumen

在网络上搜索后,我从 https://laravel.com/docs/5.1/errors#configuration

中获得了一些细节
Log::emergency($error);
Log::alert($error);
Log::critical($error);
Log::error($error);
Log::warning($error);
Log::notice($error);
Log::info($error);
Log::debug($error);

现在,例如,我只想设置仅警报、紧急情况和信息级别以进行配置。如何执行此操作。提前致谢。

Official Documentation中,你可以有一个直截了当的方式。

简单配置-

  1. 创建 .env 文件

  2. 在该文件中添加 APP_DEBUG=true

你完成了!!!!

如果您想完全控制如何为您的应用程序配置 Monolog,您可以使用该应用程序的 configureMonologUsing 方法。

自定义独白配置-

您应该在 bootstrap/app.php 文件中调用此方法:

    $app->configureMonologUsing(function($monolog) {
    $monolog->pushHandler(...);

    return $monolog;
});

return $app;

更新-

如果你发现-

Call to undefined method Laravel\Lumen\Application::configureMonologUsing()

然后,再次删除vendor/compiled.php和运行composer update

你不会再有问题了!!!!!

来源-

  1. http://laravel.io/forum/03-24-2015-call-to-undefined-method-illuminatefoundationapplicationgetcachedcompilepath

  2. https://laracasts.com/discuss/channels/general-discussion/runtimeexception-on-fresh-install?page=1