Application Insights使用log4j在java中进行日志记录 [英] Application Insights logging with log4j in java

查看:413
本文介绍了Application Insights使用log4j在java中进行日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现有 log4j应用洞察的扩展。因此,在线示例之后,我尝试配置应用程序洞察和log4j来记录生活在天蓝色托管tomcat中的servlet中的项目。

I recently discovered that there was log4j extension for application insights. So following the example online I attempted to configure application insights and log4j to log items from my servlets living in an azure hosted tomcat.

嗯,这个例子似乎非常不完整,因为它根本没有提到密钥。从浏览源码我看到一个示例(测试?)在log4j.xml中使用< param> 但没有太多解释如何使用或调试实际的记录器。

Well, the example seems very incomplete as it never makes mention of the key at all. From looking through the source I see an example (test?) that uses <param> within the log4j.xml but not much explanation of how to use or debug the actual logger.

那里有没有关于如何为log4j实际使用/实现ApplicationInsightsAppender的指针?

Does anyone out there have any pointers on how to actually use/implement the ApplicationInsightsAppender for log4j?

这里是github上的源代码 https://github.com/Microsoft/ApplicationInsights-Java

Here's the source on github https://github.com/Microsoft/ApplicationInsights-Java

推荐答案

您不必为appender配置检测密钥,如果您正确配置了AI SDK,它将自动完成。

You don't have to configure the instrumentation key for the appender, it will be done automatically if you properly configured the AI SDK.

应用程序见解的log4j扩展文章,假设您已经配置了 Application Insights for Java ,更具体地使用 AI配置文件

As mentioned in the first section of the log4j extension for application insights article, is it assumed that you already configured Application Insights for Java and more specifically configured the instrumentation key using the AI configuration file.

完成此操作后,将从配置文件中获取检测密钥。

Once you've done this, the instrumentation key will be taken from the configuration file.

appender确实有隐藏的API来设置检测密钥,但没有记录。

The appenders indeed have hidden API for setting the instrumentation key, though not documented.

这篇关于Application Insights使用log4j在java中进行日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆