Answer the question
In order to leave comments, you need to log in
How to set up Nlog for logging to ElasticSearch?
Good afternoon! please tell me how to set
up
the Nloga config in the project so that it sends logs to ELK .
Now I have Nlog writes everything to files, for example, there is a target
<target name="DebugFile" xsi:type="File" fileName="${logDirectory}Debug${logFilePrefix}"
archiveFileName="${logDirectory}Debug${archiveFilePrefix}"
layout="${fileLayout}" />
<target name="elastic" xsi:type="BufferingWrapper" index="AxBranches" uri="http://localhost:9200" flushTimeout="5000">
layout="$Debug" />
Answer the question
In order to leave comments, you need to log in
<extensions>
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<target name="ElasticSearch" xsi:type="BufferingWrapper" flushTimeout="5000">
<target xsi:type="ElasticSearch" layout="${message}" uri="http://192.168.1.1:9200/"
index="logs-${date:format=yyyy.MM.dd}">
</target>
</target>
<rules>
<logger name="*" minlevel="Warn" writeTo="ElasticSearch" />
</rules>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question