Send error to email in Laravel framework 5.3

Generally all errors of laravel are stored in files.
However in some cases you can need to send these error to email for better tracking .
Below tutorial will guide you to do do.

Now we have to open app/Exceptions/Handler.php . Find there ‘report’ function .
Here 1st parameter is path of view file and second parameter is array containing fields and message in closure .

public function report(Exception $exception)

    Mail::send('emails.errorlog', ['e' => $exception], function($message)
        $message->to('')->subject('Website error!');

Inside resources/views/errorrlog.blade.php we have:

<h3>Error Log Informtion from laravel website:</h3>
<strong>Date:</strong> {{ date('M d, Y H:iA') }}

<strong>Message:</strong> {{ $e->getMessage() }}

<strong>Code:</strong> {{ $e->getCode() }}

<strong>File:</strong> {{ $e->getFile() }}

<strong>Line:</strong> {{ $e->getLine() }}


Stack trace:

{{ $e->getTraceAsString() }}

Online Web Development Training,Video Tutorials