php 把抛出错误记录到日志中
/** * Execute the job. * * @return void */ public function handle() { try { //执行代码 (new LazadaTransactionsExportQueueJobLogic())->run($this->batchId); } catch (\Exception $exception) { $this->failed($exception); }; } /** * 任务失败的处理过程 * * @param Exception $exception * @return void */ public function failed(\Exception $exception) { $logFile = fopen( storage_path('logs' . DIRECTORY_SEPARATOR . date('Y-m-d') . '_lazada_transactions_export_queue.log'), 'a+' ); fwrite($logFile, date('Y-m-d H:i:s') . ': ' . $exception->getMessage() . PHP_EOL); fclose($logFile); }