Nlog: Log files are not archived and removed from Logs folder

Created on 12 Mar 2020  ·  4Comments  ·  Source: NLog/NLog

Issue (Question)

NLog version: v4.6.8
NLog.Config:v4.6.8
NLog.Web.AspNetCore:v4.9.0

(ASP.NET Core2)
Current NLog config (xml)

<?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="info"
    internalLogFile="C:\Logs\testProject\nlog-internal.txt">
  <extensions>
    <add assembly="NLog.Web.AspNetCore"/>
  </extensions>
<targets>
<!-- write logs to file  -->
    <target xsi:type="File" name="ALL"
        fileName="C:\Logs\testProject\${cached:${date:format=yyyy-MM-dd HH_mm_ss}}.log"
        layout="${longdate}|${uppercase:${level}}|${threadid}|${logger}|${message} ${exception:format=ToString}" 
        maxArchiveFiles="100"
        archiveFileName="C:\Logs\testProject\{#}.log"
                   archiveDateFormat="yyyy-MM-dd HH_mm_ss"
        archiveAboveSize="104857600"
        archiveNumbering="DateAndSequence"
                   maxArchiveDays="30"
        archiveEvery="Day"       
      />
</targets>

<rules>
    <logger name="*" minlevel="Trace" writeTo="ALL" />
</rules>


```

“ maxArchiveDays” not Working,and the log cannot be generated.
But if "maxArchiveDays" is removed, logs can be generated.
I need to use "maxArchiveDays"

I want to achieve the following:
log file per day.
File maximum 100MB.
Keep max 30 days of logs, automatically deleting older logs.

How can i do?
Thank you so much

file-archiving file-target question

All 4 comments

Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!

If you read the documentation:

https://github.com/NLog/NLog/wiki/File-target

Then it says:

Introduced with NLog 4.7

So you have to use NLog 4.7 RC1 or wait for the final release:

https://www.nuget.org/packages/NLog/4.7.0-rc1

If you read the documentation:

https://github.com/NLog/NLog/wiki/File-target

Then it says:

Introduced with NLog 4.7

So you have to use NLog 4.7 RC1 or wait for the final release:

https://www.nuget.org/packages/NLog/4.7.0-rc1

This means:
The version of NLog.Web.AspNetCore has nothing to do with this issue.
I need to upgrade the "NLog" and "NLog.Config" versions.

Thanks for answer

Yes NLog.Web.AspNetCore is "just" a bonus package with additional layout-output-options.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

geedsen picture geedsen  ·  3Comments

ericnewton76 picture ericnewton76  ·  3Comments

FaMouZx3 picture FaMouZx3  ·  3Comments

BobSeu picture BobSeu  ·  3Comments

imanushin picture imanushin  ·  3Comments