Reputation: 85
I am using NLog to write logs to file, which is working fine. Now I want to write logs to Elasticsearch, so I added NLog.Targets.ElasticSearch in nugets package and I configured my Nlog.config file. Unfortunately, I can't see any log information while calling http://localhost:9200/_search
In NLog.config, I added extension and targets for Elasticsearch:
<extensions>
<add assembly="NLog.Extended" />
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<targets>
<target xsi:type="ElasticSearch"
name="elastic"
layout="${logger} | ${threadid} | ${message}"
includeAllProperties="true"
uri="http://localhost:9200"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
<logger name="*" minlevel="Trace" writeTo="elastic" />
</rules>
I expect Trace type NLog should be written in Elasticsearch. Am I missing something in the config file?
By the way, I checked this doc for parameters: https://github.com/ReactiveMarkets/NLog.Targets.ElasticSearch/wiki
Upvotes: 0
Views: 3909
Reputation: 85
I just added BufferingWrapper type
and it worked. Some references to read:
Additionally, please check ElasticSearch.Net latest version in NuGet package.
You can find NLog configuration for Elasticsearch below, which is working fine for me:
<extensions>
<add assembly="NLog.Extended" />
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<target xsi:type="BufferingWrapper" name="ElasticSearch"
flushTimeout="5000">
<target xsi:type="ElasticSearch"
uri="http://localhost:9200"
includeAllProperties ="true">
</target>
</target>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
<logger name="*" minlevel="Trace" writeTo="ElasticSearch" />
</rules>
Upvotes: 3