[英]How to efficiently use logging in Google App Engine python application?
How can I print log messages for debugging purposes in a Google Cloud Endpoints Frameworks application implemented in python? 如何在以python实现的Google Cloud Endpoints Frameworks应用程序中打印日志消息以进行调试?
Since Cloud Endpoints apps are deployed on App Engine , I followed the App Engine's docs on Reading and Writing Application logs , and I tried to find my log messages on the GAE console logs . 由于Cloud Endpoints应用程序已部署在App Engine上 ,因此我按照App Engine的文档阅读和写入应用程序日志 ,并尝试在GAE 控制台日志中查找日志消息。
That did not help much though even with using all the available filters, since most log entries have hundreds of lines of nested JSON objects, and my log message will be buried in then among metadata and unrelated info in one log entry. 即使使用所有可用的过滤器,这也无济于事,因为大多数日志条目具有数百行嵌套的JSON对象,并且我的日志消息将随后埋在一个日志条目中的元数据和无关信息之间。
Is there a way to print and view log messages like I do with a simple python application running on my local machine? 有没有办法像在本地计算机上运行的简单python应用程序那样打印和查看日志消息?
You can add any filter you want in the Logs Viewer . 您可以在Logs Viewer中添加所需的任何过滤器 。 Once in there, in the dialog box that says "Filter by label or text search" you can add your filter.
进入该页面后,在显示“按标签或文本搜索过滤”的对话框中,您可以添加过滤器。 ie:
即:
resource.type="api"
resource.labels.service="[YOUR-PROJECT-ID].appspot.com"
resource.labels.method="v1.[YOUR-PROJECT-ID].EchoApi_echo"
severity="DEBUG"
These filters may vary a bit, as you may have different versions, methods etc. To familiarize yourself with these filters, if you follow this tutorial once you have finished deploying your API: 这些过滤器可能会有所不同,因为您可能具有不同的版本,方法等。要熟悉这些过滤器,如果在完成API部署后按照本教程进行操作 :
Also here you have more detailed info about using advanced filters in log viewer. 另外,您在此处还拥有有关在日志查看器中使用高级过滤器的更多详细信息。 Here about the different severity for the events (In your case looks like you are looking for severity ="DEBUG" )
这里是有关事件的不同严重性的说明(在您的情况下,您看起来是在寻找严重性=“ DEBUG”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.