I have .netcore rest api application with NLog logging mechanism. And working fine to file, email.
But now, I'm trying to ship to logz.io as mentioned in: https://docs.logz.io/shipping/log-sources/dotnet.html.
NLog config:
<?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="temp\internal-nlog.txt">
<!-- Load the ASP.NET Core plugin -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="Logzio.DotNet.NLog"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="15"
archiveFileName="${basedir}\temp\Archive\nlog-all-${shortdate}.zip"
enableArchiveFileCompression="true"
fileName="${basedir}\temp\nlog-all-dev-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target name="logzio" type="Logzio"
token="shipping-token"
logzioType="nlog"
listenerUrl="https://listener.logz.io:8071"
bufferSize="100"
bufferTimeout="00:00:05"
retriesMaxAttempts="3"
retriesInterval="00:00:02"
debug="true">
<contextproperty name="host" layout="${machinename}" />
<contextproperty name="threadid" layout="${threadid}" />
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<logger name="*" minlevel="Info" writeTo="logzio" />
</rules>
</nlog>
C# controller have this line :
private static Logger logger = LogManager.GetCurrentClassLogger();
and then I try to ship my logs using something like :
logger.Fatal("Something bad happens, ship to logz.io");
Nothing is appearing on Logz.io web portal, no logs are shipped there.
Also, checking internal-nlog.txt no error is logging
Views:
1816
Total Answered:
2
Total Marked As Answer:
1
Posted On:
06-May-2020 00:52