Python 每个http请求的嵌套日志
我想查看每个http请求的堆栈驱动程序/google日志记录上的日志。 目前,我得到了所有的日志,但由于有太多的pod,我无法将哪个日志与哪个请求关联起来 在appengine上,默认情况下,每个日志条目都是每个http请求的,并且包含来自同一请求的嵌套日志 如果有帮助的话,我正在将gunicorn与python一起使用 如果这有帮助,我就是这样写日志的:Python 每个http请求的嵌套日志,python,kubernetes,stackdriver,Python,Kubernetes,Stackdriver,我想查看每个http请求的堆栈驱动程序/google日志记录上的日志。 目前,我得到了所有的日志,但由于有太多的pod,我无法将哪个日志与哪个请求关联起来 在appengine上,默认情况下,每个日志条目都是每个http请求的,并且包含来自同一请求的嵌套日志 如果有帮助的话,我正在将gunicorn与python一起使用 如果这有帮助,我就是这样写日志的: def set_logging_env(app): logging.basicConfig(format='', level=log
def set_logging_env(app):
logging.basicConfig(format='', level=logging.INFO)
if __name__ != '__main__':
gunicorn_logger = logging.getLogger('gunicorn.info')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
有一些选项可以自定义日志记录模式。 首先,我建议大家熟悉官方文档中的基本知识 而不是有一个一般的指南 我们有: Stackdriver Logging agent为您将元数据附加到每个日志条目 稍后在查询中使用,仅选择您感兴趣的消息 in:例如,来自特定pod的消息 我想这是你寻求的东西之一 最后,您可以使用以下命令了解如何查看日志,以及稍后如何设置高级筛选器: 本指南向您介绍如何编写高级日志过滤器,这些过滤器是 表达式,可以从任意数量的 日志。可以在日志查看器中使用高级日志过滤器 Stackdriver日志API或命令行界面 此外,如果您想从Kubernetes级别检查运行吊舱中的日志,您可以使用此选项 我希望我理解正确,我的回答会很有价值。 如果有帮助,请告诉我
kubectl logs my-pod # dump pod logs (stdout)
kubectl logs -l name=myLabel # dump pod logs, with label name=myLabel (stdout)
kubectl logs my-pod --previous # dump pod logs (stdout) for a previous instantiation of a container
kubectl logs my-pod -c my-container # dump pod container logs (stdout, multi-container case)
kubectl logs -l name=myLabel -c my-container # dump pod logs, with label name=myLabel (stdout)
kubectl logs my-pod -c my-container --previous # dump pod container logs (stdout, multi-container case) for a previous instantiation of a container
kubectl logs -f my-pod # stream pod logs (stdout)
kubectl logs -f my-pod -c my-container # stream pod container logs (stdout, multi-container case)
kubectl logs -f -l name=myLabel --all-containers # stream all pods logs with label name=myLabel (stdout)