[英]Send logs of libraries used in python to google cloud stackdriver logging
[英]Google Cloud Stackdriver ignores formatting in Python logs
我正在使用python37
運行時部署 Cloud Function。 感謝這個問題,我知道我可以將 Python 本機記錄器連接到 Stackdriver 記錄。 所以我的雲 Function 看起來像這樣:
import logging
logging.basicConfig(format="%(module)s.%(funcName)s: %(message)s", level=logging.INFO)
from google.cloud import logging as glogging
glogging.Client().setup_logging()
def endpoint():
logging.info("this should be prefixed with main.endpoint")
return "ok"
但是當我在 Stackdriver 中查看生成的日志時:
ERROR
嚴重性。 google-cloud-logging
中的某些內容似乎只處理消息而忽略了其他所有內容。 有沒有辦法將它傳遞給我定義的格式化程序?
為什么日志會重復?
當我在本地運行代碼時,我得到了這個:
main.endpoint: this should be prefixed with main.endpoint
this should be prefixed with main.endpoint
Waiting up to 5 seconds.
Sent all pending logs.
所以,圖書館似乎在復制日志。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.