LoggingAppender getting `projectId` from service account key json instead of env variable `GOOGLE_CLOUD_PROJECT`

36 views Asked by At

I have these two variables set in intellij GOOGLE_CLOUD_PROJECT and SPRING_CLOUD_GCP_LOGGING_PROJECT_ID but still LoggingAppender class is getting projectId null and ultimately reading from service account Json file. What is the issue?

my logback-spring.xml

<configuration debug="true">

    <include resource="com/google/cloud/spring/logging/logback-appender.xml"/>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

    <root level="INFO">
        <appender-ref ref="STACKDRIVER"/>
    </root>
</configuration>

version of dependencies

<properties>
        <java.version>1.8</java.version>
        <spring-cloud-gcp.version>3.7.5</spring-cloud-gcp.version>
        <spring-cloud.version>2021.0.9</spring-cloud.version>
</properties>

In class LoggingAppender the variable LoggingOptions.Builder loggingOptionsBuilder = LoggingOptions.newBuilder(); is null. But super.getLoggingOptions() has proper logger values from environment variable.

enter image description here

1

There are 1 answers

0
Mehul Parmar On

The issue was with spring-cloud-gcp-logging library. It is fixed here - https://github.com/GoogleCloudPlatform/spring-cloud-gcp/pull/2501