LoginSignup
5
5

More than 5 years have passed since last update.

HerokuのLaravelでエラーをログに吐く。

Posted at

HerokuでLaravelのエラー確認できるようにする

config/app.php
    /*
    |--------------------------------------------------------------------------
    | Logging Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log settings for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Settings: "single", "daily", "syslog", "errorlog"
    |
    */

    'log' => 'errorlog',// 変更する

エラー吐いてみる

app/Http/routes.php
Route::get('/err', function () {
    trigger_error("エラーのテスト!", E_USER_ERROR);
});

ログの確認

% heroku logs
2015-12-01T06:09:42.407367+00:00 app[web.1]: 10.144.102.111 - - [01/Dec/2015:06:09:42 +0000] "GET /err HTTP/1.1" 500 4519 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
2015-12-01T06:09:42.394469+00:00 app[web.1]: [01-Dec-2015 06:09:42 UTC] [2015-12-01 06:09:42] production.ERROR: exception 'ErrorException' with message 'エラーのテスト!' in /app/app/Http/routes.php:19
2015-12-01T06:09:42.394475+00:00 app[web.1]: Stack trace:
2015-12-01T06:09:42.394739+00:00 app[web.1]: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(256, '\xE3\x82\xA8\xE3\x83\xA9\xE3\x83\xBC\xE3\x81\xAE\xE3\x83\x86...', '/app/app/Http/r...', 19, Array)
2015-12-01T06:09:42.394941+00:00 app[web.1]: #1 /app/app/Http/routes.php(19): trigger_error('\xE3\x82\xA8\xE3\x83\xA9\xE3\x83\xBC\xE3\x81\xAE\xE3\x83\x86...', 256)
2015-12-01T06:09:42.395049+00:00 app[web.1]: #2 [internal function]: App\Providers\RouteServiceProvider->{closure}()
2015-12-01T06:09:42.395159+00:00 app[web.1]: #3 /app/bootstrap/cache/compiled.php(7832): call_user_func_array(Object(Closure), Array)
2015-12-01T06:09:42.395901+00:00 app[web.1]: #4 /app/bootstrap/cache/compiled.php(7819): Illuminate\Routing\Route->runCallable(Object(Illuminate\Http\Request))
2015-12-01T06:09:42.397029+00:00 app[web.1]: #6 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
2015-12-01T06:09:42.399977+00:00 app[web.1]: #8 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
2015-12-01T06:09:42.400909+00:00 app[web.1]: #10 /app/bootstrap/cache/compiled.php(7476): Illuminate\Pipeline\Pipeline->then(Object(Closure))
2015-12-01T06:09:42.402385+00:00 app[web.1]: #12 /app/bootstrap/cache/compiled.php(7449): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
2015-12-01T06:09:42.403954+00:00 app[web.1]: #14 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
2015-12-01T06:09:42.404078+00:00 app[web.1]: #15 /app/bootstrap/cache/compiled.php(9581): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
2015-12-01T06:09:42.405427+00:00 app[web.1]: #16 /app/bootstrap/cache/compiled.php(2926): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5