java 记录 Google App Engine 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3124712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 00:28:51  来源:igfitidea点击:

Logging Google App Engine application

javagoogle-app-engine

提问by newbie

I have made my GAE application using the development server, but now when I deploy it to GAE cloud, some features don't work (some elements are missing), but no exceptions are thrown.

我已经使用开发服务器制作了我的 GAE 应用程序,但是现在当我将它部署到 GAE 云时,某些功能不起作用(缺少某些元素),但没有抛出异常。

Now I'd like to have some logging to my code so I could find out why these things are working in development environment, but not in GAE cloud, but I haven't found a way to log events like I can do with the development server in Eclipse.

现在我想对我的代码进行一些日志记录,以便我可以找出为什么这些东西在开发环境中有效,但在 GAE 云中无效,但是我还没有找到一种方法来记录事件,就像我在开发中可以做的那样Eclipse 中的服务器。

So is it possible to log events like you can do in the Eclipse development server?

那么是否可以像在 Eclipse 开发服务器中那样记录事件?

回答by brainjam

Google App Engine applications written in Java can write information to the log files using java.util.logging.Logger. Log data for an application can be viewed and analyzed using the Administration Console, or downloaded using appcfg.sh request_logs.

用 Java 编写的 Google App Engine 应用程序可以使用 java.util.logging.Logger 将信息写入日志文件。可以使用管理控制台查看和分析应用程序的日志数据,或使用 appcfg.sh request_logs 下载。

More info in the Logging documentation.

日志记录文档中的更多信息。

回答by naikus

You will have to configure logging via java.util.logging.Logger and a logging.properties file in your classpath, preferably in your WEB-INF/classes/directory. e.g. if you want all your logging to be at the INFO level, the contents of this file should be:

您必须通过 java.util.logging.Logger 和类路径中的 logging.properties 文件配置日志记录,最好在WEB-INF/classes/目录中。例如,如果您希望所有日志记录都在 INFO 级别,则此文件的内容应为:

# Set the default logging level for all loggers to INFO
.level = INFO

回答by freedev

The article that was marked as correct answer is a little bit outdated.

被标记为正确答案的文章有点过时了。

Today if you have to read your logs or want remotely debug your app you can use

今天,如果您必须阅读日志或想要远程调试您的应用程序,您可以使用

Java GAE applications still write information to the log files using java.util.logging.Logger.

Java GAE 应用程序仍然使用java.util.logging.Logger.

Again, if you want more information about the Google App Engine Java loggingread the documentation.

同样,如果您想了解有关Google App Engine Java 日志记录的更多信息,请阅读文档。

回答by Sumitha

I assume you are asking for the Log console to see the error info and such. if yes then open your Google app engine launcher and click on your app and you can see a Logs button on the top next to Run and Stop. Good luck!

我假设您要求日志控制台查看错误信息等。如果是,则打开您的 Google 应用引擎启动器并单击您的应用,您可以在顶部的运行和停止旁边看到一个日志按钮。祝你好运!