C
C#6mo ago
walter9830

NLog configuration file issues.

<?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"
internalLogFile="c:\temp\internal-nlog-AspNetCore.txt">

<extensions>
<add assembly="NLog.Web.AspNetCore" />
</extensions>

<targets>
<target xsi:type="File" name="auditlog" filename="{basedir}\Logs\Main\${shortdate}.txt" layout="[ApiAuditLog] | Logger: ${logger} | ${time} | Details: ${message}" />
<target xsi:type="File" name="servicelog" filename="{basedir}\Logs\Main\${shortdate}.txt" layout="[ServiceLog] | Logger: ${logger} | ${time} | Details: ${message}" />
<target xsi:type="File" name="exceptionfile" filename="{basedir}\Logs\Exceptions\${shortdate}.txt" layout="[ExceptionLog] | Logger: ${logger} | ${time} | Details: ${message}"/>/>
</targets>

<rules>
<logger name="Microsoft.*" maxLevel="info" final="true" />
<logger name="GameStore.API.Middlewares.RequestResponseLoggingMiddleware*" minlevel="Info" writeTo="auditlog" final="true"/>
<logger name="GameStore.BLL.Services*" minlevel="Info" writeTo="servicelog" final="true"/>
<logger name="*ExceptionHandlingMiddleware*" minlevel="Error" writeto="exceptionfile" />
</rules>
</nlog>
<?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"
internalLogFile="c:\temp\internal-nlog-AspNetCore.txt">

<extensions>
<add assembly="NLog.Web.AspNetCore" />
</extensions>

<targets>
<target xsi:type="File" name="auditlog" filename="{basedir}\Logs\Main\${shortdate}.txt" layout="[ApiAuditLog] | Logger: ${logger} | ${time} | Details: ${message}" />
<target xsi:type="File" name="servicelog" filename="{basedir}\Logs\Main\${shortdate}.txt" layout="[ServiceLog] | Logger: ${logger} | ${time} | Details: ${message}" />
<target xsi:type="File" name="exceptionfile" filename="{basedir}\Logs\Exceptions\${shortdate}.txt" layout="[ExceptionLog] | Logger: ${logger} | ${time} | Details: ${message}"/>/>
</targets>

<rules>
<logger name="Microsoft.*" maxLevel="info" final="true" />
<logger name="GameStore.API.Middlewares.RequestResponseLoggingMiddleware*" minlevel="Info" writeTo="auditlog" final="true"/>
<logger name="GameStore.BLL.Services*" minlevel="Info" writeTo="servicelog" final="true"/>
<logger name="*ExceptionHandlingMiddleware*" minlevel="Error" writeto="exceptionfile" />
</rules>
</nlog>
this is my nlog.config file, however when doing some stuff (that logs both for the servicelog and the auditlog) the only resulting text in the .txt file is the servicelog. What could be the issue? I have attached a screenshot of the resulting log.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server