Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize Laravel error reporting to remove stack trace

Tags:

php

laravel

How can you turn off or remove the stack traces from Laravel's error reports. They're annoying if you want to read them in your console. I know you can add a custom handler in app/Exceptions/Handler.php, but I have no idea how to do that.

like image 762
Angelo A Avatar asked Jun 01 '15 21:06

Angelo A


1 Answers

Setting APP_DEBUG=false in your .env file works fine for the frontend.

If you don't want the stack trace lines to be outputted in the log files only, try this.

In /app/Exceptions/Handler.php add use Log; at the top, then add this in the report function:

Log::error('['.$e->getCode().'] "'.$e->getMessage().'" on line '.$e->getTrace()[0]['line'].' of file '.$e->getTrace()[0]['file']);

And remove:

parent::report($e);

More info: https://laracasts.com/discuss/channels/laravel/remove-stacktrace-from-log-files

like image 74
Harold Avatar answered Oct 24 '22 10:10

Harold