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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.