索取应用洞察力 [英] Solr to Application Insights

查看:58
本文介绍了索取应用洞察力的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置Solr日志以发送到Azure Application Insights?

How can I configure Solr logs to get sent to Azure Application Insights?

我看到可以使用Log4J附加程序. https://docs.microsoft. com/en-us/azure/application-insights/app-insights-java-trace-logs

I see can use a Log4J appender. https://docs.microsoft.com/en-us/azure/application-insights/app-insights-java-trace-logs

Solr是一个开源项目,我自己不编译它,我只使用发行版.

Solr is an open source project, and I don't compile it myself, I just use the distribution.

如何在不重新安装SDK的情况下放入Application Insights/Log4J附加程序? 我只想配置日志以发送到应用程序信息,以有效地进行第三方应用程序. 并配置检测键.

How can I drop in Application Insights/Log4J appender, without recompiling having installed the SDK? I just want to configure the logs to get sent to application insghts, for effectively a 3rd party application. And configure the instrumentation key.

我通常是C#开发人员,但熟悉Log4Net.因此,如果Java Log4J中的代码很简单,那么就使用appology.找不到适合这种情况的帖子,请在此处发布.

I'm normally a C# dev, but familiar with Log4Net. So appologies if this is simple in Java Log4J. Not been able to find a post for this scenario so posting here.

使用Solr 6.6.

Using Solr 6.6.

推荐答案

所需的配置比您期望的要少得多,并且大多数信息隐藏在您已经拥有的链接中: https://docs.microsoft.com/zh-CN/azure/azure-monitor/app/java-trace-logs

It takes a lot less configuration than you'd expect, and most of the info is hidden away in the link that you've already got: https://docs.microsoft.com/en-gb/azure/azure-monitor/app/java-trace-logs

首先,从 https://github.com/Microsoft/ApplicationInsights下载jar文件-Java/发行版.您需要applicationinsights-logging-log4j1_2-2.3.0applicationinsights-core-2.3.0.将它们放在server/lib文件夹中,Solr会自动为您加载它们.

First, go download the jar files from https://github.com/Microsoft/ApplicationInsights-Java/releases. You'll want applicationinsights-logging-log4j1_2-2.3.0 and applicationinsights-core-2.3.0. Put these in the server/lib folder and Solr will load them automatically for you.

接下来,您需要为您的log4j.properties文件添加新的appender,以了解应用程序

Next you''ll need to add a new appender for app insights into your log4j.properties file

# Appinsights
log4j.appender.aiAppender=com.microsoft.applicationinsights.log4j.v1_2.ApplicationInsightsAppender
log4j.appender.aiAppender.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.aiAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n

您还需要将此aiAppender添加到同一文件的log4j.rootLogger列表中(它可能看起来像这样:log4j.rootLogger=INFO, file, CONSOLE, aiAppender)

You also need to add this aiAppender to the log4j.rootLogger list in the same file (it'll probably look something like this: log4j.rootLogger=INFO, file, CONSOLE, aiAppender)

最后,您需要一个ApplicationInsights.xml文件,您可以从这里获取一个示例

Finally, you need an ApplicationInsights.xml file, which you can get an example of from here https://docs.microsoft.com/en-gb/azure/azure-monitor/app/java-get-started#2-add-the-application-insights-sdk-for-java-to-your-project

将其拖放到server/resources文件夹中,设置您的检测密钥,就可以了!

Drop this in the server/resources folder, set your instrumentation key and you're good to go!

这篇关于索取应用洞察力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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