【发布时间】:2019-04-15 18:51:56
【问题描述】:
我们有一个 .Net Web 应用程序,并且我们已经在记录到 csv 文件。我们刚刚开始使用 Elastic search 进行日志记录。我可以在 Kibana 上看到日志,但此处没有显示来自应用程序添加到 LogEventInfo 的信息,尽管我可以看到 contentLength 根据发送的信息长度而更改。我只能在 Kibana 中查看每个日志的 http 详细信息。你能告诉我可能是什么问题吗?
配置看起来像
<target name="elastic" xsi:type="BufferingWrapper" flushTimeout="5000">
<target xsi:type="ElasticSearch" uri="http://<url>:<portNumber>/">
<field name ="MachineName" layout="${machinename}" layoutType="System.String" />
</target>
</target>
Kibana 上不显示机器名称等数据,我可以在同时创建的 csv 日志中看到它。
nlog 配置。配置部分规则写入日志
" <logger name="*" minLevel="Info" writeTo="elk" enabled="true" />"
使用以下代码记录数据:
var theEvent= new LogEventInfo( logLevel,this.logger.Name,activityInfo.LogMessage // The message to log. );
theEvent.Properties[APPLICATION_NAME] = applicationName;
theEvent.Properties[ACTIVITY_NAME] = activityInfo.ActivityName;
this.logger.Log (theEvent); –
【问题讨论】:
-
配置什么?日志数据如何记录到 ES 中?
-
nlog 配置。配置部分中写入日志的规则“
” 使用以下代码记录数据: var theEvent= new LogEventInfo( logLevel,this. logger.Name,activityInfo.LogMessage // 要记录的消息。); theEvent.Properties[APPLICATION_NAME] = 应用程序名称; theEvent.Properties[ACTIVITY_NAME] = activityInfo.ActivityName; this.logger.Log (theEvent);
标签: asp.net elasticsearch logging nlog