如果 App Engine 自动记录 stdout 和 stdout,为什么还要使用logging.properties? stderr 到 INFO &警告?

发布于 2024-08-06 21:13:41 字数 997 浏览 4 评论 0原文

根据 Google App Engine for Java 的文档:

App Engine Java SDK 包括 模板logging.properties文件,在 appengine-java-sdk/config/user/ 目录。要使用它,请将文件复制到 您的 WEB-INF/classes 目录(或 战争中的其他地方),然后系统 属性 java.util.logging.config.file 到 “WEB-INF/classes/logging.properties” (或者无论你选择哪条路, 相对于应用程序根目录)。你 可以在系统属性中设置 appengine-web.xml 文件,如下:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    ...

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/classes/logging.properties" />
    </system-properties>

</appengine-web-app>

Eclipse 的 Google 插件新 项目向导创建这些日志记录 为您提供的配置文件,以及 将它们复制到 WEB-INF/classes/ 自动地。对于 java.util.logging, 您必须将系统属性设置为 使用此文件。

如果您写入标准输出或标准错误,则会自动记录为信息或警告。

那么,为什么需要使用日志记录.properties 文件?

这是否可以让您对日志记录进行一些额外的控制?

According to the documentation for Google App Engine for Java:

The App Engine Java SDK includes a
template logging.properties file, in
the appengine-java-sdk/config/user/
directory. To use it, copy the file to
your WEB-INF/classes directory (or
elsewhere in the WAR), then the system
property java.util.logging.config.file
to
"WEB-INF/classes/logging.properties"
(or whichever path you choose,
relative to the application root). You
can set system properties in the
appengine-web.xml file, as follows:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    ...

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/classes/logging.properties" />
    </system-properties>

</appengine-web-app>

The Google Plugin for Eclipse new
project wizard creates these logging
configuration files for you, and
copies them to WEB-INF/classes/
automatically. For java.util.logging,
you must set the system property to
use this file.

If your write to standard out or standard error, that will automatically get logged as INFO or WARNING.

So, why do you need to use a logging.properties file?

Does this give you some additional control over your logging?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不在是我 2024-08-13 21:13:41

如果您想使用更具体的日志记录信息,例如一些 DEBUG。

这样您就可以在开发过程中记录更多信息,并且在将代码投入生产时无需更改代码。

个人示例:当我编码时,我会记录很多信息(记录级别“FINE”和“FINEST”)。当我将应用程序发送给测试人员时,他们使用调试级别。在生产环境中(向公众),只有信息、警告和严重信息会被记录。

总之,这给了您更多的控制权,并且您不必更改任何代码行。

有关 java 登录的更多信息:此处

If you want to use more specific logging info, like some DEBUG.

This way you can log more info during development, and you don't need to change your code when you put your code in production.

Personal example: When I code, I log a lot of info ( logging Level FINE, and FINEST). When I send my application to tester, they use DEBUG level. In production (to public) only INFO, WARNING and SEVERE are log.

In conclusion , this give you more control, and you don't have to change any line of code.

For more info about logging in java : here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文