Azure 应用程序洞察与 Spring Boot 日志问题

问题描述 投票:0回答:2

我已经启动并运行了 azure spring boot 服务,我在 Azure 中配置了应用程序洞察。我有以下代码更改

pom.xml如下

    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>applicationinsights-spring-boot-starter</artifactId>
        <version>2.6.4</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>applicationinsights-logging-logback</artifactId>
        <version>2.6.4</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>applicationinsights-core</artifactId>
        <version>2.6.4</version>
    </dependency>

我的logback-spring.xml如下。

<springProperty scope="context" name="INSTRUMENTATION_KEY"
    source="azure.application-insights.instrumentation-key"/>

  <appender name="aiAppender"
    class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
    <instrumentationKey>${INSTRUMENTATION_KEY}</instrumentationKey>
  </appender>

我的 application.yml 文件如下,

azure:
  application-insights:
    instrumentation-key: <my_instrumentation_key>
    enabled: true
    web:
      enabled: true
    logger:
      level: info

此配置工作正常,如果我在本地运行应用程序,则会将日志推送到 Azure AI。但是当我将其推送到 Azure 时,我没有看到任何日志被推送。请帮助我解决这个问题,因为过去三天我一直在碰头。

spring spring-boot azure azure-application-insights
2个回答
0
投票

将applicationinsights-agent.jar的版本更改为3.2.4后已解决


0
投票

添加依赖

implementation 'com.microsoft.azure:applicationinsights-runtime-attach:3.4.16'

使用连接字符串在

applicationinsights.json
中添加
src/main/resources/

{
  "connectionString": ""
}

在main方法中添加

ApplicationInsights.attach();
© www.soinside.com 2019 - 2024. All rights reserved.