Laravel logs in Heroku not showing up
Asked Answered
V

1

11

I've deployed a Laravel app to heroku by following the official guide. It says to change APP_LOG=errorlog, which I've done.

I've also tried two different versions of this, the commented line being the variation.

$this->app->configureMonologUsing(function($monolog){
    // $monolog->pushHandler(new \Monolog\Handler\SyslogHandler('papertrail')); 
    $monolog->pushHandler(new \Monolog\Handler\StreamHandler('php://stderr', \Monolog\Logger::WARNING));
});

If I use Log::error('something') I'm not seeing anything. I'm looking in both papertrail, and the CLI command heroku logs --tail --app {appname}

Vevay answered 24/11, 2017 at 13:28 Comment(0)
D
12

You must set LOG_CHANNEL=errorlog as a Heroku environment variable. This setting is for Laravel 5.6, in older versions it was other. (and that "old" information is found on most internet sites, when searching for the problem)

This information can be found in .env file, which values must be manually set in Heroku.

Why? The .env is not transferred to heroku, because it is listed in .gitignore.

BTW: I had the same issue today, seems like the setting you tried was valid for an older version of Laravel. I now use 5.6.

Dextrality answered 1/7, 2018 at 20:7 Comment(3)
I had trouble finding 'old' setting for version 5.3 so here it is just for reference: APP_LOG=errorlog, when I set this in heroku settings-> config vars, then I see the logs. This env variable is used in config/app.php on version 5.3 and default value is 'single' which sets writing to storage/logs/laravel.log file.Boogeyman
It's worth mentioning that Heroku's official docs for Laravel specifically have not been updated. LOG_CHANNEL is in fact the correct environment variable to set to have Laravel application logs to show up in heroku logsNegotiation
@Dextrality : I have updated the same in laravel 7 but still no successAphonic

© 2022 - 2024 — McMap. All rights reserved.