spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

[help needed] Stackdriver logging sample configuration for Java 11 App Engine #1644

Closed ludoch closed 5 years ago

ludoch commented 5 years ago

I cloned the GCP logging sample to my repo and adapted a bit the pom (still pointing to my project!) and the app.yaml to target GAE Java11 with fatjar mode. After deployment, I see this cryptic error message and the server does not boot:

A Exception in thread "main" java.lang.reflect.InvocationTargetException A at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) A at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) A at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) A at java.base/java.lang.reflect.Method.invoke(Method.java:566) A at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) A at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) A at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) A at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) A Caused by: java.lang.IllegalStateException: Logback configuration error detected:
A ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [STACKDRIVER]. Did you define it below instead of above in the configuration file? A ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details. A at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169) A at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:82) A at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60) A at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:117) A at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:292) A at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:265) A at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:228) A at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:201) A at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) A at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) A at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) A at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) A at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) A at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) A at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347) A at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) A at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) A at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) A at com.example.Application.main(Application.java:32)

ludoch commented 5 years ago

Sample code is located at:

https://github.com/ludoch/samples/tree/master/java11/spring-cloud-gcp-logging-sample

meltsufin commented 5 years ago

I believe this is a duplicate of https://github.com/spring-cloud/spring-cloud-gcp/issues/1628

ludoch commented 5 years ago

I think so as well... Thanks! https://github.com/spring-cloud/spring-cloud-gcp/issues/1643 would have helped a bit.

ludoch commented 5 years ago

https://springboot-springcloud-logging-dot-openjdk11.appspot.com/log works now with GAE Java11. I'll update the sample on my side.

ludoch commented 5 years ago

I had to add a second dep:

    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter-logging</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-gcp-autoconfigure</artifactId>
    </dependency> 

to get the autoconfigure file...

ludoch commented 5 years ago

Will my app break again when I switch to newer GCP integration without changing the xml config? Would that be OK with semver?

meltsufin commented 5 years ago

spring-cloud-gcp-starter-logging includes spring-cloud-gcp-autoconfigure as a transitive dep. So, adding it explicitly shouldn't change anything. Can you share you whole pom.xml?

meltsufin commented 5 years ago

Re-open if the issue is not resolved.