开发者

Why would you use logging.properties if App Engine automatically logs stdout & stderr to INFO & WARNING?

开发者 https://www.devze.com 2022-12-08 04:45 出处:网络
According to the documentation for Google App Engine for Java: The App Engine Java SDK includes a template logging.properties file, in

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 jav开发者_开发问答a.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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消