Nlog Parameter maxArchiveDays not supported on FileTarget

Viewed 603

Using NLog.Web.AspNetCore 4.9.2
My config looks like this:

<targets>
    <target name="logFile" xsi:type="File" 
            fileName="logs/log-${shortdate}.txt" 
            layout="${longdate}|${level:uppercase=true}|${logger}|${message}"
            archiveFileName="logs/archive/log-{#}.txt"
            archiveNumbering="Date"
            archiveDateFormat="yyyy-MM-dd"
            archiveOldFileOnStartup="true"
            maxArchiveDays="1"/>
</targets>

I recieve the following error:

Exception when parsing .\Settings\NLog.config.
Parameter maxArchiveDays not supported on FileTarget

Thanks in advance

1 Answers

I believe you're using the NLog.Web.AspNetCore package.
This package has a dependency to

NLog.Extensions.Logging (>= 1.6.2)

which itself depends on

NLog (>= 4.6.8 && < 5.0.0-beta01)

So when you add the package to a .NET Core 3.0 project, here's what you got: enter image description here

As you can see, NLog version 4.6.8 is installed, which does not support this parameter indeed.

There is actually an issue on the package repo so I think the update to next version is planned.

In the meantime, adding the NLog package to the project solve the error.

Install-Package NLog -Version 4.7.2

Related