简体   繁体   English

如何有效使用Google App Engine python应用程序中的日志记录?

[英]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部署后按照本教程进行操作

  1. in the section Tracking API activity click on "View Endpoints Request Logs". 在“ 跟踪API活动 ”部分中,单击“查看端点请求日志”。
  2. There you will see that it automatically filtered the results by "Produced API" -> "Service you created" -> "Method created". 在那里,您将看到它通过“ Produced API”->“您创建的服务”->“方法创建”自动过滤了结果。
  3. If you click in any of the Logs entries, you can click in any of its fields, for example click on "severity". 如果单击任何“日志”条目,则可以单击其任何字段,例如,单击“严重性”。 It will say: "Show matching entries" 它会说:“显示匹配的条目”
  4. It will automatically create an advanced filter similar to the one I wrote before. 它将自动创建一个高级过滤器,类似于我之前编写的过滤器。

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.

相关问题 如何在Google App Engine中动态更改python应用程序的日志记录级别? - How to dynamically change logging level of python app in Google App Engine? 如何更改Google App Engine Python生产服务器中的日志记录级别? - How to change logging level in google app engine python production server? Google App Engine / Python - 更改日志记录格式 - Google App Engine/Python - Change logging formatting 如何在Google App Engine中有效地扩展数据库? - How to scale database efficiently in Google App Engine? 如何使用OAuth从Python应用程序访问Google App Engine端点API? - How can I access Google App Engine endpoints API from Python application with use OAuth? 如何在Google App Engine Python中使用Google Cloud Vision? - How to use google cloud vision with Google App Engine Python? python日志记录不适用于使用Google App Engine的Web应用程序 - python logging does not work for web app using google app engine 如何使用Python在Google App Engine中使用应用程序部署映像 - How to Deploy an Image with the Application in Google App Engine Using Python 如何将数据从Google App Engine(Python)传递到Flex 4应用程序 - How to pass data from Google App Engine(Python) to Flex 4 application 如何在Google App Engine Python应用程序之间共享模块之间的会话? - How to share sessions between modules on a Google App Engine Python application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM