2

I'm preparing to migrate from GAE Java 8 Standard Runtime to Java 11 Standard Runtime. I have been using java.util.logging. I understand that with Java 11 runtime, logs are no longer correlated automatically. With Java 8 Runtime, all the log messages for a particular request would appear nested within the particular request's log entry. But now, all log messages appear independently.

To address this issue, I followed the documentation to use Google Cloud Logging. However, I don't see any difference at all in my logs with or without Google Cloud Logging. The logs are still not correlated.

My test application is a single servlet application developed using the HelloWorld sample.

I've added this dependency to my pom.xml:

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-logging</artifactId>
    <version>1.101.2</version>
</dependency>

My logging.properties file is similar to the sample in the documentation and is located in src/main/resources/ folder.

.level = INFO

# it is recommended that io.grpc and sun.net logging level is kept at INFO level,
# as both these packages are used by Stackdriver internals and can result in verbose / initialization problems.
io.grpc.netty.level=INFO
sun.net.level=INFO

com.mycompany.services.main.MyClass.handlers=com.google.cloud.logging.LoggingHandler
# default : java.log
com.google.cloud.logging.LoggingHandler.log=custom_log

# default : INFO
com.google.cloud.logging.LoggingHandler.level=FINE

# default : ERROR
com.google.cloud.logging.LoggingHandler.flushLevel=ERROR

# default : auto-detected, fallback "global"
com.google.cloud.logging.LoggingHandler.resourceType=container

# custom formatter
com.google.cloud.logging.LoggingHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s

Here's the command used for deployment:

mvn clean package appengine:deploy -Dapp.deploy.projectId=my-project-id -Djava.util.logging.config.file=src/main/resources/logging.properties

In the logs, I see an entry like the following when the server is started:

2020-07-11 06:32:33.111:INFO::main: Logging initialized @920ms to org.eclipse.jetty.util.log.StdErrLog

What do I need to do to get correlated logs as I get with Java 8 Runtime?

DFB
  • 861
  • 10
  • 25
  • I found a related stackoverflow case [here](https://stackoverflow.com/a/60191131/10682174) that might be helpful – Adebisi Jul 14 '20 at 13:06
  • @Adebisi I've read that article before. I don't use Spring GCP. Moreover, I have tried adding Google Client Logging Library as a dependency, and it adds about 50MB to the runtime memory of the app (almost unbelievable). – DFB Jul 18 '20 at 07:19
  • same issue here. i've tried a bunch of iterations and still no solution. this ridiculous... – gabereal Oct 20 '20 at 20:12

0 Answers0