[英]Google App Engine Logging in NodeJS
I can't find much on logging onto Google App Engine using Flexible environment and NodeJS. 在使用Flexible环境和NodeJS登录Google App Engine方面,我找不到很多东西。
As the docs says , one is able to write its own logging messages using the standard stdout
and stderr
. 正如文档所述 ,人们可以使用标准
stdout
和stderr
编写自己的日志记录消息。 But this is simple logging, and I would like to have something a little bit more refined. 但这是简单的日志记录,我想做一点改进。
In particular, the Log Views in Google Cloud Platform Console allows the user to filter logs on their severity levels: 尤其是,用户可以使用Google Cloud Platform Console中的“日志视图”来按照其严重性级别过滤日志:
I would like to find a way to use those levels in my applications, so that I can read logs much better. 我想找到一种在我的应用程序中使用这些级别的方法,以便可以更好地读取日志。
By default, if I print to stdout
using console.log()
the logs will only appear if I filter by "Any log level", and I have no option to select a severity level. 默认情况下,如果我使用
console.log()
打印到stdout
,则只有在按“任何日志级别”过滤时,日志才会出现,并且我没有选择严重性级别的选项。
I have tried to use winston-gae
as reported on the docs , but without any success. 我尝试使用docs上报告的
winston-gae
,但没有成功。 Maybe I have configured it wrong? 也许我配置错了?
To be more clear, I would like to be able to do something like this in Python ( source ): 更清楚地说,我希望能够在Python( 源 )中执行以下操作:
import logging
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')
self.response.out.write('Logging example.')
app = webapp2.WSGIApplication([
('/', MainPage)
], debug=True)
我建议您查看Google Cloud Node.js客户端库,它可以帮助您调用Stackdriver Logging API以便记录结构化日志条目: https : //github.com/GoogleCloudPlatform/google-cloud-node#google- stackdriver-logging-beta
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.