【问题标题】:Include ApplicationName in GCP Cloud Logging Spring Boot在 GCP Cloud Logging Spring Boot 中包含 ApplicationName
【发布时间】:2022-12-03 21:52:02
【问题描述】:

In microservices arch, built on spring boot, i am sending all logs in prod to GCP logging, which is working fine. But the logs doesn\'t include the application name. Since, the microservices uses a common starter artifcat, so there are a lot of similar logs, and it is hard to identify that which services is producing the log. So how to configure the logging to also include application name ? Basically, i am looking for a way to figure that the log is coming from which microservice ?

Changes in pom.xml
<properties>
        <spring-cloud-gcp-starter-logging.version>1.2.8.RELEASE</spring-cloud-gcp-starter-logging.version>
</properties>

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-gcp-starter-logging</artifactId>
   <version>${spring-cloud-gcp-starter-logging.version}</version>
</dependency>

And below is logback-spring.xml

<configuration>
    <include resource=\"org/springframework/boot/logging/logback/defaults.xml\"/>
    <include resource=\"org/springframework/boot/logging/logback/console-appender.xml\"/>
    <include resource=\"org/springframework/cloud/gcp/logging/logback-appender.xml\"/>
    <include resource=\"org/springframework/cloud/gcp/logging/logback-json-appender.xml\"/>

    <springProfile name=\"dev\">
        <root level=\"INFO\">
            <appender-ref ref=\"CONSOLE\"/>
            <!--            <appender-ref ref=\"CONSOLE_JSON\"/>-->
        </root>
    </springProfile>

    <springProfile name=\"prod\">
        <root level=\"INFO\">
            <appender-ref ref=\"CONSOLE\"/>
            <!--            <appender-ref ref=\"CONSOLE_JSON\"/>-->
            <appender-ref ref=\"STACKDRIVER\"/>
        </root>
    </springProfile>

</configuration>

    标签: java spring spring-boot google-cloud-platform google-cloud-logging


    【解决方案1】:
    猜你喜欢
    • 2018-12-15
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    • 2021-02-25
    • 2018-05-27
    • 2019-07-27
    • 2019-01-07
    • 1970-01-01
    相关资源
    最近更新 更多