Purnima Naik
Purnima Naik

Reputation: 2683

NLog always creates 1KB file, even when 'archiveAboveSize' value is set > than 1KB in .net core

NLog always creates 1KB file, even when 'archiveAboveSize' value is set > than 1KB Following is my nlog.config file.

<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <variable name="LayoutFooter" value="----------------------------------------"/>
  <targets>
    <target name="infoInstrumentation"
      xsi:type="File"
      concurrentWrites="false"
      archiveFileName="D:\Logs\Instrumentation.${shortdate}.{##}.log"
      archiveAboveSize="5"
      archiveNumbering="Rolling"
      maxArchiveFiles="10"
      fileName="D:\Logs\Instrumentation.${shortdate}.log"
      layout="Timestamp: ${date}${newline}${all-event-properties:format=[key]\: [value]:separator=\&#xD;&#xA;}${newline}Message: ${message}${newline}Machine: ${machinename}${newline}${newline}${LayoutFooter}"
    keepFileOpen="false">
    </target>
    <target name="errorInstrumentation"
     xsi:type="File"
     concurrentWrites="false"
     archiveFileName="D:\Logs\Instrumentation.${shortdate}.{##}.log"
     archiveAboveSize="5"
     archiveNumbering="Rolling"
     maxArchiveFiles="10"
     fileName="D:\Logs\Instrumentation.${shortdate}.log"
     layout="Timestamp: ${date}${newline}${all-event-properties:format=[key]\: [value]:separator=\&#xD;&#xA;}${newline}Message: ${message}${newline}StackTrace: ${exception:format=toString}${newline}Machine: ${machinename}${newline}${newline}${LayoutFooter}"
     keepFileOpen="false">
    </target>
  </targets>
  <rules>
    <logger name="ServiceLogger" level="Info" writeTo="infoInstrumentation"/>
    <logger name="ServiceLogger" level="Error" writeTo="errorInstrumentation"/>
  </rules>
</nlog>

When code runs, it just keeps on creating 1KB file, instead of creating file of size 5KB.

I am using following version of NLog in my .net core project: "NLog.Extensions.Logging": "1.0.0-rtm-beta1"

Upvotes: 0

Views: 553

Answers (1)

Julian
Julian

Reputation: 36830

This is a known issue. It seems that file-creation time doesn't always give correct values.

See https://github.com/NLog/NLog/issues/1633

NLog is working on a fix.

Upvotes: 1

Related Questions