如何在appengine中记录异常?
try:
#do something that raises an exception...
except:
logging.error('Error Message')
我希望日志中显示的不仅仅是“错误消息”。我想在日志中查看回溯,或者至少查看异常是什么。我该怎么做?
谢谢!
try:
#do something that raises an exception...
except:
logging.error('Error Message')
I want more than just "Error Message" to show in the logs. I want to see the traceback, or at least what the exception was, in the logs as well. How do I do that?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
logging.exception(msg[, *args])
在根记录器上记录一条 ERROR 级别的消息。这些参数被解释为 debug()。异常信息添加到日志消息中。该函数只能从异常处理程序中调用。
http://docs.python.org/library/logging.html#logging.exception
logging.exception(msg[, *args])
Logs a message with level ERROR on the root logger. The arguments are interpreted as for debug(). Exception info is added to the logging message. This function should only be called from an exception handler.
http://docs.python.org/library/logging.html#logging.exception
这是我用来记录整个堆栈跟踪的内容:
This is what I use to log the entire stack trace:
我认为这应该对你有帮助
I think this should help you
您可以将日志记录详细信息设置为“调试”、“信息”、“警告”、“错误”或“严重”,并在应用程序中进行设置。调试会给你很多细节。
您可以在 appengine Web 控制台的 /logs 下获取特定过滤器的日志。
You can set the logging details to Debug,Info,Warning,Error or Critical and set in your application. Debug would give you a lot of details.
And you can get the logs of the particular filter in your appengine web console under /logs.