【问题标题】:Google cloud logging, using python with docker container谷歌云日志,使用 python 和 docker 容器
【发布时间】:2015-07-21 05:33:01
【问题描述】:

我有一个简单的 python 应用程序并想使用谷歌云日志记录。我使用 docker 并使用 kubernetes 运行它。

如何将日志发送到谷歌云日志?

import time
import logging

def main():
    logging.basicConfig()
    logging.getLogger().setLevel(logging.INFO)
    try:
        while True:
            logging.info('Working...')
            time.sleep(1)
    except KeyboardInterrupt:
        logging.info('Stopped working')
        pass;

if __name__ == '__main__':
    main()

【问题讨论】:

  • 对不起,我忘了说,我更新了问题thx

标签: python google-compute-engine kubernetes google-kubernetes-engine google-cloud-logging


【解决方案1】:

如果您将记录器配置为写入标准输出,Kubernetes 会自动为您将其发送到 Google Cloud Logging。

否则,您将不得不使用 sidecar 容器来收集日志并为您上传它们,例如在 this example 中。

【讨论】:

猜你喜欢
  • 2021-05-15
  • 2016-06-18
  • 1970-01-01
  • 1970-01-01
  • 2014-12-04
  • 2020-07-24
  • 2016-04-17
  • 1970-01-01
  • 2021-02-15
相关资源
最近更新 更多