I'm having problems with logging some basic info line from Console. Locally, this works fine, everything gets logged (errors, info messages) from web and from console. But on server, error logging works fine, but when i call logger myself and try to log some info message it does not work.
I'm using Laravel 5.4 version.
This is some App\Console\Commands\DummyCommand class for test purposes.
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Log\Writer as Log;
class DummyCommand extends Command
{
/**
* Create a new console command instance.
*
* @param \Illuminate\Log\Writer $log
* @return void
*/
public function __construct(Log $log)
{
parent::__construct();
$this->log = $log;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$message = "Some dummy message";
$this->info($message); // gets printed on console both locally and on server
$this->log->info($message);
$ret = $this->log->getMonolog()->addInfo($message);
dump($ret); // locally = true, server = false
if ($ret === false) {
throw new \Exception('Error while logging!'); // this log works fine both locally and on server
}
}
}
Any idea why is this not working ? Permissions on storage folder is fine for all folders and files. Error messages (exceptions) gets logged but info messages does not.
Edited: This is working, I need to add following line before calling $this->log->info(); but there is no way i would use on all Commands and every time need to set path to log file.
$this->log->useDailyFiles(storage_path().'/logs/laravel.log');
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2p7agub
via IFTTT
Aucun commentaire:
Enregistrer un commentaire