根据 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.
如果您写入标准输出或标准错误,将自动记录为 INFO 或 WARNING。
那么,为什么需要使用 logging.properties
文件?
这会让您对日志记录有一些额外的控制吗?
最佳答案
如果您想使用更具体的日志记录信息,例如一些 DEBUG。
这样您就可以在开发过程中记录更多信息,并且在将代码投入生产时无需更改代码。
个人示例:当我编码时,我会记录很多信息(记录级别 FINE 和 FINEST)。当我将我的应用程序发送给测试人员时,他们使用 DEBUG 级别。在生产环境中(对公众)只有 INFO、WARNING 和 SEVERE 是日志。
总而言之,这为您提供了更多控制权,并且您无需更改任何代码行。
有关在 java 中登录的更多信息:here
关于java - 如果 App Engine 自动将 stdout & stderr 记录到 INFO & WARNING,你为什么要使用 logging.properties?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1517884/