I log some stuff with LogEventInfo
, because I'm adding a variable property called Action
to each log. In my target the layout
is simple, layout="${message}"
, but fileName
is complex, fileName="C:\log\${date:format=yyyy-MM-dd HH-mm-ss} ${event-properties:item=Action}.log"
.
But I still want to restrict the space taken with all these log files. It doesn't matter if it's by size, or date, or number of files. How do I archive log files with such custom file name?
There is an answer from 2013 stating that this is not possible, but I'm hoping that that answer is now incorrect, even if it was correct back then.
In the end my solution was to delete all *.log files from the folder, except the N newest ones, before I write a new log. These logs are not of the regular kind, so special cleanup for special logging case is fine.