Laravel队列禁用失败的工作数据库记录
有没有办法在工作失败时禁用Laravel的数据库记录?
例如,我只是想编写一个日志消息,这对此特定的作业足够:
job.php
public function handle()
{
//making an API request to an external API, storing some data inside cache
}
public function failed(Throwable $exception)
{
Log::info("external API update failed");
}
我已经尝试编辑config/queue.php
file by:
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => null,
'table' => null,
],
这不起作用,有什么想法如何获取失败的作业的数据库记录?
Is there a way to disable the database logging of laravel when a job failed?
For example I'm just trying to write a log message, which would enough for this specific job:
job.php
public function handle()
{
//making an API request to an external API, storing some data inside cache
}
public function failed(Throwable $exception)
{
Log::info("external API update failed");
}
I already tried to edit the config/queue.php
file by:
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => null,
'table' => null,
],
This doesn't work, any idea how to get the database logging of failed jobs disabled?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您必须将
config/queue.php
设置为以下内容:您应该能够在项目中的供应商文件夹中的
laravel/framework/framework/framework
文件夹中找到线索,例如供应商/laravel/framework/src/inluminate/queue/databasefailedjobprovider.php。
对数据库的保存是在
databasefailedjobprovider
类中完成的,log> log
函数。基于
QueueserviceProvider
'sregisterfailedJobServices
函数,您需要将驱动程序设置为null
或'null''或'null'字符串才能获得它要运行nullfailedjobprovider
,其中日志函数为空。I believe you have to set
config/queue.php
to the following:You should be able to find clues within the
laravel/framework
folder within the vendor folder in your project, e.g.vendor/laravel/framework/src/Illuminate/Queue/DatabaseFailedJobProvider.php.
The saving to database is done in the
DatabaseFailedJobProvider
class, thelog
function specifically.Based on the
QueueServiceProvider
'sregisterFailedJobServices
function, you would need to set the driver tonull
or the 'null' string in order to get it to run theNullFailedJobProvider
, where the log function is empty.