Closed chenzhe014 closed 5 years ago
Instead of jumping into the deep end of the pool, then try something simple.
Forexample this setting will carry a lot of suprises:
<default-wrapper xsi:type="BufferingWrapper" bufferSize="5"/>
Instead try this NLog.config instead:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="internal-nlog.txt">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<!-- define various log targets -->
<variable name="logDirectory" value="${basedir}/logs/${shortdate}"/>
<targets async="true">
<target xsi:type="File"
name="allfile"
fileName="${logDirectory}/nlog-all/${shortdate}.log"
keepFileOpen="true"
concurrentWrites="false"
/>
<target xsi:type="File"
name="ownLog-file"
fileName="${logDirectory}/nlog-${level}/${shortdate}.log"
keepFileOpen="true"
concurrentWrites="false"
/>
<target xsi:type="ElasticSearch" name="elastic" layout="${logger} | ${threadid} | ${message}" index="qunar_api" includeAllProperties="true" requireAuth="true" username="****" password="******" uri="http://localhost:9210" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="allfile" />
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="*" minlevel="Info" writeTo="elastic" />
</rules>
</nlog>
Have you checked the output of the NLog InternalLogger for any issues? See also https://github.com/NLog/NLog/wiki/Internal-Logging
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
i want to add fileds in my logs from elasticsearch .
But it will only be recorded in local files,and will not be recorded in elasticsearch. when i append
logger.LogInformation("n")
(Microsoft.Extensions.Logging) . it will be recorded in elasticsearch. I have tried this many times and this is always the result.Log Code:
Nlog.Config