Azure Application Insights 控制台日志格式

标签 azure spring-boot logging logback azure-application-insights

我正在开发一个使用 azure Application Insights 的 spring-boot 应用程序。 我为控制台中显示的日志定义了格式,并使用 logback 配置了

<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
        <layout>
            <Pattern>%d{ISO8601} %level class=%C{1.} %X{requestKey} msg=%msg%n%throwable </Pattern>
        </layout>
</appender>

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

问题是AI在cosole中显示的日志如下:

2020-01-10 08:47:58,089 INFO class=org.springframework.boot.web.embedded.tomcat.TomcatWebServer  msg=Tomcat initialized with port(s): 8080 (http)
2020-01-10 08:47:58,802 INFO class=org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext  msg=Root WebApplicationContext: initialization completed in 8435 ms
AI: INFO 10-01-2020 07:48:00.819+0000, 1(main): Agent is not running

我不想以这种方式显示 AI:日志,我的意思是,我想将此类跟踪格式更改为控制台附加程序中定义的相同格式:

2020-01-10 08:47:58,802 INFO class=com.microsoft.blabla.ApplicationInsights msg=Agent is not running

是否可以更改此类跟踪格式?

提前致谢

最佳答案

您看到的格式是内部 AI 调试日志记录格式,例如

    AI: INFO 10-01-2020 07:48:00.819+0000, 1(main): Agent is not running

目前无法更改此格式。

但是,如果您想分享反馈,请这样做 here有关您想要实现的场景的更多详细信息,这将使产品团队能够相应地评估要求。谢谢

关于Azure Application Insights 控制台日志格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59677454/

相关文章:

Azure函数: Is using gcServer recommended for consumption plans?

web-applications - 基于 Azure 的 GPS 数据记录器和 map 查看器

spring-boot - @Scheduled 和 @Async 在 spring-boot 中共享相同的线程池

url - 在不记录每次点击的情况下估算每小时 URL 点击次数的聪明方法?

c# - Azure AD API 始终将 System.Security.Principal.GenericIdentity.IsAuthenticated 返回为 false

Azure VM 虚拟网络相互通信

java - 具有 Vaadin UI 的 Spring Boot 应用程序不断刷新屏幕

java - 在 JpaRepository 中使用外键

java - 如何更改 slf4j 日志记录级别

java - 将特定的 SLF4J 记录器与嵌入的 Jetty 相关联