Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save summercms/e9eea014c184a160d9ee53acee18a343 to your computer and use it in GitHub Desktop.

Select an option

Save summercms/e9eea014c184a160d9ee53acee18a343 to your computer and use it in GitHub Desktop.

Revisions

  1. Martin Vach revised this gist May 21, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions laravel-removing-stack-traces.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    Removing the error stack traces from logging in Laravel
    ===
    By default errors in Laravel are logged with the error stack traces. If you want to turn off these annoying stack traces perform the following:
    1. Open
    ```
  2. Martin Vach created this gist Apr 26, 2019.
    36 changes: 36 additions & 0 deletions laravel-removing-stack-traces.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    By default errors in Laravel are logged with the error stack traces. If you want to turn off these annoying stack traces perform the following:
    1. Open
    ```
    app/Exceptions/Handler.php`
    ```
    2. Add
    ```
    use Illuminate\Support\Facades\Log;`
    ```
    3. Modify the report method:
    ```
    /**
    * Report or log an exception.
    *
    * @param \Exception $exception
    * @return void
    */
    public function report(Exception $exception)
    {
    // Some exceptions don't have a message
    $exception_message = (!empty($exception->getMessage()) ? trim($exception->getMessage()) : 'App Error Exception');
    // Log message
    $log_message = "\"" . $exception_message . " in file '" . $exception->getFile() . "' on line '" . $exception->getLine() . "'" . "\"";
    if (!config('app.debug')) {
    Log::error($log_message);
    } else {
    parent::report($exception);
    }
    }
    ```
    ## Sources
    - [Laravel 5 remove stack trace](https://stackoverflow.com/questions/30583567/laravel-5-remove-stack-trace)
    - [Stop adding stacktrace details](https://stackoverflow.com/questions/23798958/laravel-stop-adding-stacktrace-details)