How do I map my java app logging events to corresponding cloud logging event levels in GCP Felexible non-compat App Engine?

后端 未结 2 941
梦如初夏
梦如初夏 2020-12-06 06:07

I am new to GCP AppEngine and I chose the Flexible environment for several reasons. However, I am shocked to find out that the flexible environment\'s non-\"compatible\" ru

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 06:53

    The log levels provided by java.util.logging will map to the appropriate log levels in Cloud Logging. Logging on Flexible runtimes essentially works the same as it does on Standard.

    Edit: It seems the rationale for the 'Writing Application Logs' page is that the Cloud Logging mappings don't work for all of the runtimes. However, they do seem to currently work for at least the '-compat' runtimes and Java custom runtimes. Workarounds for others are provided elsewhere in the docs (see below):

    The recommended default method of logging in a Java application is to use java.util.logging (for Python it's the 'logging' module, and for Go it's the 'log' package, all of which provide log levels which map to Cloud Logging levels). I'll request that these pages get updated.

    The other documents you linked to provide accurate information about logging for Java. Regarding the section you quoted, the full paragraph it was pulled from provides context. It's saying any logging framework that writes to stderr or stdout will work, but it needs to use 'java.util.logging' if you want more fine-grained log levels other than 'INFO' or 'WARNING'. A full code sample for using 'java.util.logging' is provided directly underneath the quoted section, and others are provided on the other document you mentioned, 'Logging Application Events with Java'.

    Update: The 'Getting Started' guides contain specific details on how to configure logging for each runtime:

    Java
    https://cloud.google.com/java/getting-started/logging-application-events#understanding_the_code

    Python
    https://cloud.google.com/python/getting-started/logging-application-events#understanding_the_code

    Go
    https://cloud.google.com/go/getting-started/logging-application-events

    NodeJS
    https://cloud.google.com/nodejs/getting-started/logging-application-events#understanding_the_code

    Ruby
    https://cloud.google.com/ruby/getting-started/logging-application-events#application_structure

    PHP
    https://cloud.google.com/php/getting-started/logging-application-events

提交回复
热议问题