Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel to send email for logging instead of writing to storage

I've looked through the documentation and can't find a way to change the logging for any errors, which normally write to /app/storage/logs/logs/log-apache2handler-xxxx-xx-xx.txt

but on the production server, I want any of those to be emailed to me instead.

Is there a way to do this?

like image 490
Wizzard Avatar asked Oct 18 '13 20:10

Wizzard


2 Answers

use package like

Begin by installing this package through Composer. Edit your project's composer.json file to require dinesh/bugonemail.

Or visit

http://dineshrabara.github.io/bugonemail/

like image 141
Dinesh Rabara Avatar answered Oct 23 '22 10:10

Dinesh Rabara


I still log the error, and if it's production, send an email with the exception:

App::error(function(Exception $exception, $code)
{
Log::error($exception);

if (Config::getEnvironment() == 'production')
{
    $data = array('exception' => $exception);
    Mail::send('emails.error', $data, function($message)
    {
        $message->from($email_app);
        $message->to(Config::get('settings.error_email'))->subject(Config::get('settings.app_name') . ' Error');
    });
    Log::info('Error Email sent to ' . Config::get('settings.error_email'));
    return Response::view('errors.500', array(), 500);
}
});
like image 41
Rufhausen Avatar answered Oct 23 '22 08:10

Rufhausen