簡體   English   中英

Symfony - 禁止記錄特定端點

[英]Symfony - suppress logging for specific endpoint

我有一個特定的端點,我在其中放置了一個空響應:

/**
 * @Route("/ping", name="ping")
 * @return JsonResponse
 */
public function gcpPingAction(): JsonResponse
{
    return $this->json([], Response::HTTP_OK);
}

在我的日志中,我得到:

在此處輸入圖像描述

是否可以以某種方式抑制被命中的端點的日志記錄? 只是為了那個特定的端點..

根據this ,您應該可以這樣做。

monolog:
    handlers:
        main:
            # ...
            type: fingers_crossed
            handler: ...
            excluded_http_codes: [{ 200: ['^/ping$'] }]

或者像這樣

monolog:
    handlers:
        main:
            # ...
            type: fingers_crossed
            handler: ...
            excluded_http_codes:
                - urls:
                    - '^/ping$'

但是,我沒有測試它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM