Reputation: 8013
NLog's file target is pretty configurable, but it doesn't seem to support what I am trying to achieve.
My console application writes messages to a log file, but I want it to do two things:
x
latest runs as well.The archive* properties seem to be pretty close, but they do the rolling on a time basis, not an execution basis.
Upvotes: 2
Views: 1088
Reputation: 11214
The first is somewhat easy. Set the filename to "log-${cached:${date:format=yyyyMMdd_HH_mm_ss}}.log"
or something similar. This will set up the file with a down-to-the-second name, which will be cached on each application execution.
As far as your second request, that's a bit more difficult. You might try setting archiveEvery: "None"
and maxArchiveFiles: x
, but I'm not sure if that would produce the desired behaviour or just never archive anything at all.
Upvotes: 5