0

我有 2 个使用 azure application Insights 的 Spring Boot 应用程序。两者都使用相同的依赖项、相同的检测密钥、相同的应用程序属性。但是在一项服务中,日志正在获取应用程序洞察力,而另一项服务不打印日志。我使用 azure 门户检查了这一点。

我调试了启用记录器级别进行跟踪,并在服务 2 中发现以下错误日志,该日志未将日志写入应用程序洞察力。

第二项服务正在将日志打印到控制台和滚动文件,但在 Azure 门户中看不到日志。请建议我为什么会收到 400 错误,因为哪些日志没有发送到 application-insights

build.gradle 中的依赖项:

api "com.microsoft.azure:applicationinsights-spring-boot-starter:1.0.0-BETA"
api "com.microsoft.azure:applicationinsights-logging-logback:2.0.+"

application.yaml 中的属性:

azure:
  application-insights:
    instrumentation-key: instm-key
    enabled: true
    web:
      enabled: true
    logger:
      level: trace

logback-spring.xml:

    <appender name="aiAppender"
        class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
    </appender> 

    <root level="ERROR">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="ROLLINGFILE" />
      <appender-ref ref="aiAppender" /> 
    </root>

控制台日志:

AI: TRACE 02-08-2019 18:54:53.208, 26(localhost-startStop-1): Registering PC 'DeadLockDetector'
AI: TRACE 02-08-2019 18:54:53.208, 26(localhost-startStop-1): Failed to store performance counter 'DeadLockDetector', since there is already one
AI: TRACE 02-08-2019 18:54:53.208, 26(localhost-startStop-1): Registering PC 'JvmHeapMemoryUsedPerformanceCounter'
AI: TRACE 02-08-2019 18:54:53.208, 26(localhost-startStop-1): Failed to store performance counter 'JvmHeapMemoryUsedPerformanceCounter', since there is already one
AI: ERROR 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to create WindowsPerformanceCounterAsPC: 'java.lang.Exception: Failed to register all built-in Windows performance counters.'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Registering PC 'JSDK_ProcessMemoryPerformanceCounter'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to store performance counter 'JSDK_ProcessMemoryPerformanceCounter', since there is already one
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Registering PC 'JSDK_ProcessCpuPerformanceCounter'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to store performance counter 'JSDK_ProcessCpuPerformanceCounter', since there is already one
AI: ERROR 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to create WindowsPerformanceCounterAsPC: 'java.lang.Exception: Failed to register all built-in Windows performance counters.'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Registering PC 'JSDK_ProcessMemoryPerformanceCounter'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to store performance counter 'JSDK_ProcessMemoryPerformanceCounter', since there is already one
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Registering PC 'JSDK_ProcessCpuPerformanceCounter'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to store performance counter 'JSDK_ProcessCpuPerformanceCounter', since there is already one
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Registering PC 'DeadLockDetector'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to store performance counter 'DeadLockDetector', since there is already one
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Registering PC 'JvmHeapMemoryUsedPerformanceCounter'
AI: TRACE 02-08-2019 18:54:53.211, 26(localhost-startStop-1): Failed to store performance counter 'JvmHeapMemoryUsedPerformanceCounter', since there is already one
AI: INFO 02-08-2019 18:54:54.510, 26(localhost-startStop-1): Agent was not found. Skipping the agent registration
AI: TRACE 02-08-2019 18:54:55.895, 37(ActiveTransmissionNetworkOutput_1-0): Http response code 400 not handled by com.microsoft.applicationinsights.internal.channel.common.ErrorHandler
AI: TRACE 02-08-2019 18:54:55.895, 37(ActiveTransmissionNetworkOutput_1-0): Http response code 400 not handled by com.microsoft.applicationinsights.internal.channel.common.PartialSuccessHandler
AI: TRACE 02-08-2019 18:54:55.907, 37(ActiveTransmissionNetworkOutput_1-0): Http response code 400 not handled by com.microsoft.applicationinsights.internal.channel.common.ThrottlingHandler.
AI: TRACE 02-08-2019 18:55:03.161, 41(ActiveTransmissionNetworkOutput_1-1): Http response code 400 not handled by com.microsoft.applicationinsights.internal.channel.common.ErrorHandler
AI: TRACE 02-08-2019 18:55:03.161, 41(ActiveTransmissionNetworkOutput_1-1): Http response code 400 not handled by com.microsoft.applicationinsights.internal.channel.common.PartialSuccessHandler
AI: TRACE 02-08-2019 18:55:03.161, 41(ActiveTransmissionNetworkOutput_1-1): Http response code 400 not handled by com.microsoft.applicationinsights.internal.channel.common.ThrottlingHandler.
4

1 回答 1

0

这里提到的旧版本存在一些已知的 logback 问题:

https://github.com/Microsoft/ApplicationInsights-Java/issues/453

请尝试使用最新的 Application Insights Java SDK

https://github.com/Microsoft/ApplicationInsights-Java/releases

于 2019-08-23T10:29:00.997 回答