Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old files are not getting deleted on Windows server #4174

Closed
ymetelkin opened this issue Nov 16, 2020 · 5 comments
Closed

Old files are not getting deleted on Windows server #4174

ymetelkin opened this issue Nov 16, 2020 · 5 comments
Labels
file-archiving Issues with archiving with the file target file-target needs info

Comments

@ymetelkin
Copy link

Deleting of old files does not work on our production server but works on my development machine.
NLog version 4.7.5
NET Framework 4.7.2
Server: AWS EC2 Windows
Configuration:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
      <target name="logfile" xsi:type="File" fileName="${basedir}/logs/${shortdate}.log" maxArchiveDays="1" maxArchiveFiles="1" encoding="utf-8" keepFileOpen="true"/>
    </targets>
    <rules>
      <logger name="*" level="Info" writeTo="logfile" />
    </rules>
  </nlog>
@welcome
Copy link

welcome bot commented Nov 16, 2020

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

@304NotModified
Copy link
Member

That sounds a permission error.
Please enable and check the internal log

@repo-ranger
Copy link
Contributor

repo-ranger bot commented Nov 16, 2020

Please add the requested info, so we could help you better! (This issue will be closed in 7 days)

@snakefoot snakefoot added file-archiving Issues with archiving with the file target file-target labels Nov 16, 2020
@ymetelkin
Copy link
Author

The internal log is attached.
nlog-internal.txt

@snakefoot
Copy link
Contributor

Looks like your NLog.config shown in intial topic is not matching the output from nlog-internal.txt

2020-11-20 15:10:47.0603 Debug FileTarget(Name=logfile): Preparing for new file 'C:\AP\SearchAPI\/logs/current.log'

According to nlog-internal.txt then you have configured it like this:

FileName="${basedir}/logs/current.log"
ArchiveFileName="${basedir}/logs/${shortdate}.log"

It is not supported to use ${shortdate} for ArchiveFileName. See also #3807 (comment) and #4105 (comment)

@repo-ranger repo-ranger bot closed this as completed Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
file-archiving Issues with archiving with the file target file-target needs info
Projects
None yet
Development

No branches or pull requests

3 participants