3

Is there a configuration in NLOG that accomplishes the following

1)A new log file should be created , when the current file exceeds a particular size for ex:- 5 MB

2)The old log files should be deleted after a configured amount of time period like for ex: - 1 day

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Sabarish Sathasivan
  • 1,196
  • 2
  • 19
  • 42

1 Answers1

7

You can find answer for your question (and examples) on page:

Size-based file archival - log files can be automatically archived by moving them to another location after reaching certain size and

Time-based file archival - log files can calso be automatically archived based on time

Try to use the second one and change log files every days. Than you can keep maximum number of archived files.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
Tomasz Dzięcielewski
  • 3,829
  • 4
  • 33
  • 47
  • The requirement is that When the size of a log file exceeds 1 MB, a new log file should be created and old files should be deleted based on their age – Sabarish Sathasivan Oct 18 '12 at 12:27
  • Maybe try to write two targets: one will archive files bigger than 1MB, second will remove old ones. Of course second shouldn't write any info to file. – Tomasz Dzięcielewski Oct 18 '12 at 12:52
  • The links above are broken, but you can reference similar information here: https://github.com/nlog/NLog/wiki/File-target – wilsjd Aug 09 '13 at 18:12