Laravel队列禁用失败的工作数据库记录

发布于 2025-02-12 19:23:21 字数 568 浏览 0 评论 0原文

有没有办法在工作失败时禁用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫卆 2025-02-19 19:23:21

我相信您必须将config/queue.php设置为以下内容:

'failed' => [
    'driver' => null
    'database' => null,
    'table' => null,
],

您应该能够在项目中的供应商文件夹中的laravel/framework/framework/framework文件夹中找到线索,例如
供应商/laravel/framework/src/inluminate/queue/databasefailedjobprovider.php。

对数据库的保存是在databasefailedjobprovider类中完成的,log> log函数。

基于QueueserviceProvider's registerfailedJobServices函数,您需要将驱动程序设置为null或'null''或'null'字符串才能获得它要运行nullfailedjobprovider,其中日志函数为空。

I believe you have to set config/queue.php to the following:

'failed' => [
    'driver' => null
    'database' => null,
    'table' => null,
],

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, the log function specifically.

Based on the QueueServiceProvider's registerFailedJobServices function, you would need to set the driver to null or the 'null' string in order to get it to run the NullFailedJobProvider, where the log function is empty.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文