通常,当我进行编码时,我只喜欢将一些小东西(主要是变量的当前值)打印到控制台。虽然我注意到谷歌应用引擎启动器确实有一个日志终端,但我在谷歌应用引擎上没有看到这样的东西。有没有办法使用谷歌应用引擎向上述终端或其他终端写信?
您将需要使用Python的标准日志记录
模块。
import logging
logging.info("hello")
logging.debug("hi") # this won t show up by default
要在GoogleAppEngineLauncher日志控制台中查看对logging.debug()
的调用,您必须首先将标志--dev_appserver_log_level=debug
添加到您的应用程序中。然而,请注意,您将看到来自应用程序引擎SDK本身的大量调试噪音。整套级别为:
debug
info
warning
error
critical
您可以通过双击应用程序,然后将其放入额外标志字段来添加标志。
See https://cloud.google.com/appengine/docs/python/requests#Python_Logging
and http://docs.python.org/library/logging.html
您可能想要使用以下内容:
logging.debug("value of my var is %s", str(var))
@曼乔尔
你可以在java中做同样的事情。
import java.util.logging.Logger;
// ...
public class MyServlet extends HttpServlet {
private static final Logger log = Logger.getLogger(MyServlet.class.getName());
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
log.info("An informational message.");
log.warning("A warning message.");
log.severe("An error message.");
}
}
如果您使用的是最新版本的Python Development Server(版本>;1.7.6,或2013年3月及更高版本),这些步骤似乎是正确的使用步骤:
在脚本中包含以下内容,
import logging logging.debug("something I want to log")
根据此文档页面,通过转到“编辑”>“应用程序设置”>“启动设置”>>“额外命令行标志”来设置标志,并添加,
--log_level=调试
您还应该看一下FirePython。它允许您在firebug中获取服务器日志消息。
http://appengine-cookbook.appspot.com/recipe/firepython-logger-console-inside-firebug/
在我的网站上查看我在谷歌应用引擎上运行的在线Python解释器,学习Python。这可能就是你想要的。只需在你想看的东西上使用print repr(变量),并根据你的需要执行多次。
您好,我使用的是GoogleAppEngineLauncher的1.8.6版本,您可以使用标志来设置您想要查看的消息日志级别,例如调试消息:
--dev_appserver_log_level调试
使用它而不是--debug
(请参阅@Christopher的回答)。
GAE将捕获标准错误并将其打印到控制台或日志中。
print >> sys.stderr, "Something to log."
使用log.setLevel(Level.ALL)查看消息
默认的邮件筛选级别似乎是错误的。直到我使用setLevel()方法使.info和.warning消息可见,我才看到任何有用的日志消息。
打印到System.out的文本也没有显示。它似乎被解释为log.info()级别的消息。
我希望我在回答这个问题。日志记录消息打印到AppEngine日志,而不是终端。
You can launch it by clicking on the logs button of the AppEngine Launcher
使用日志记录
模块是一种很好的做法,但不是必需的。
您只需执行普通的print()
操作即可写入Google应用程序引擎日志控制台。
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding