When using the task scheduler in Laravel 5.1 I am redirecting command output to a log file. It is working as expected except for the fact that it is truncating the log file before it writes, every time.
This does not for a very useful log file make.
$schedule->command('queue:work')->everyMinute()->sendOutputTo(storage_path() . "/logs/mail.log");
I can't find anything about preventing this truncation in the laravel docs .
Does anyone know how to prevent this behavior?
In Laravel 5.3 they added the option appendOutputTo() who does the job. Much easier :)
$schedule->command('emails:send')
->daily()
->appendOutputTo($filePath);
see it in documentation appendOutputTo in documentation
You can not do this with Event class. This will help:
$schedule->command('queue:work')->everyMinute()->sendOutputTo(storage_path() . "/logs/mail.recent");
File::append(storage_path() . "/logs/mail.log", File::get(storage_path() . "/logs/mail.recent"));
Not very beautifull but the only way as i know. Also dont forget to add use File;
to the top
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.