簡體   English   中英

為什么我的模塊雲記錄器日志沒有出現在 Google Cloud Logging 中?

[英]Why do my module cloud logger logs not appear in Google Cloud Logging?

當從 Google Cloud Functions 中的模塊記錄器記錄日志時,調用 Cloud Function 時,日志不會存儲在 Google Cloud Logging 中。 來自 Python日志記錄模塊的記錄器使用與 Google Cloud Logging 的集成,如下所示

我創建了一個示例代碼來說明這種行為。 main.py 文件如下:

import logging
import google.cloud.logging
from google.cloud.logging.handlers import CloudLoggingHandler


client = google.cloud.logging.Client()
handler = CloudLoggingHandler(client, name='module_logger_log')
module_logger = logging.getLogger('module_logger')
module_logger.setLevel(logging.DEBUG)
module_logger.addHandler(handler)
module_logger.info('log info: module_logger created')


def cf_endpoint(req):
    # Testing all severities
    module_logger.debug('log debug')
    module_logger.info('log info')
    module_logger.warning('log warning')
    module_logger.error('log error')
    module_logger.critical('log critical')

    return 'ok'

部署是 HTTP 觸發的,使用 Python 3.8,入口點是 function cf_endpoint ,requirements.txt 文件如下:

google-cloud-logging==2.0.2

可以在此處找到存儲在 Google Cloud Logging 中的部署和觸發代碼的日志。 正如可以理解的那樣,來自部署的日志出現了,但是來自入口點的日志不存在。

有沒有人經歷過這種錯誤行為或者我忽略了什么?

提前致謝。

最好打開一個問題跟蹤器,因為這樣可以讓 GCP 支持將其傳遞給適當的團隊以解決此問題。

暫無
暫無

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

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