我试图弄清楚如何在Laravel 5中向我的电子邮件发送错误.我没有太多运气找到任何好的资源.
I am trying to figure out how I can send errors to my email in Laravel 5. I haven't had much luck finding any good resources.
曾经有一些不错的软件包,例如: github/TheMonkeys/laravel-error-emailer 这是在Laravel 4中为您完成的.
There used to be good packages like: github/TheMonkeys/laravel-error-emailer That did this for you in Laravel 4.
由于他们更改错误处理的方式,他们尚未发布Laravel5更新...我也不熟悉.
They have yet to release a Laravel5 update because of the way they changed error handling... which I am also not to familiar with.
我有一些Laravel 5应用程序需要监视,但除了检查存储中的错误日志外,我还需要一种更有效的方法.
I have a few Laravel 5 applications which I need to monitor but I need a more efficient way of doing it besides checking error logs on storage.
任何帮助将不胜感激.我知道还有其他人也在寻求这些信息.
Any help would be greatly appreciated. I know there are others out there seeking this information as well.
推荐答案您可以通过捕获App\Exceptions\Handler::report()中的所有错误来做到这一点.因此,在App/Exceptions/Handler.php中添加report函数(如果尚不存在的话).
You can do this by catching all the errors in the App\Exceptions\Handler::report(). So in you App/Exceptions/Handler.php add a report function if its not already there.
/** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Exception $e * @return void */ public function report(\Exception $e) { if ($e instanceof \Exception) { // emails.exception is the template of your email // it will have access to the $error that we are passing below Mail::send('emails.exception', ['error' => $e->getMessage()], function ($m) { $m->to('your email', 'your name')->subject('your email subject'); }); } return parent::report($e); }如果您需要更多信息,请参阅laravel文档表格邮件程序和错误.
If you need more info, refer to laravel documentation form mailer and errors.
更多推荐
Laravel 5将错误发送到电子邮件
发布评论