Python登录到GCP StackDriver缺少日志类型图标
我使用这种方法将日志从我的GCP应用程序引擎逻辑发送到GCP Stackdriver日志:Python登录到GCP StackDriver缺少日志类型图标,python,logging,google-cloud-platform,stackdriver,Python,Logging,Google Cloud Platform,Stackdriver,我使用这种方法将日志从我的GCP应用程序引擎逻辑发送到GCP Stackdriver日志: import logging import google.cloud.logging from google.cloud.logging.handlers import CloudLoggingHandler, setup_logging client = google.cloud.logging.Client() handler = CloudLoggingHandler(client) loggin
import logging
import google.cloud.logging
from google.cloud.logging.handlers import CloudLoggingHandler, setup_logging
client = google.cloud.logging.Client()
handler = CloudLoggingHandler(client)
logging.getLogger().setLevel(logging.INFO)
setup_logging(handler)
logging.info('just info')
logging.warning('warning info')
logging.error('bad news')
这将工作并生成所有一般分类的日志,如下所示:
然而,我希望看到的是相同的日志,但具有相关的严重性级别分类,并且直观地具有日志级别分类图标,如示例中所示:
我查阅了文档,找到并尝试了很多方法,但都没有得到相同的结果。欢迎任何建议。您需要做的是为每个条目设置日志严重性。例如,对于'just info',您可以将严重性设置为'info',这将为您提供示例中显示的蓝色方框。查看此内容,了解所有严重程度及其含义。在研究了该问题并跟踪了大量死角线索后,我在该网站上找到了一个可行的答案: 简而言之,我通过StreamHandler使用Stackdriver格式遵循他的解决方案。现在,这使我能够生成正确的严重性级别格式的日志条目,这些条目可以在GCP日志中正确过滤: