Solr 到应用程序洞察 [英] Solr to Application Insights

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

问题描述

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

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

我看到可以使用 Log4J appender.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 appender?我只想配置日志以发送到应用程序 insghts,以有效地作为 3rd 方应用程序.并配置检测键.

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 中很简单,那么很抱歉.无法找到有关此场景的帖子,因此请在此处发帖.

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/en-gb/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=信息,文件,控制台,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 文件,您可以从这里获取示例 https://docs.microsoft.com/en-gb/azure/azure-monitor/app/java-get-started#2-add-the-application-insights-sdk-for-java-to-your-project

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!

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

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