How can I barrel a text logfile?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How can I barrel a text logfile?

alano
Hi, hope someone can help.

I've read the documentation right through and can't find the answer myself...

I wish to log to a basic text logfile, limiting the log file size to a set limit (e.g. 5MB) such that, when writing a new entry, NLog will automatically delete oldest entries in order to ensure the logfile does not exceed the set size limit (thus barreling entries in the log).

I don't wish to archive contents into new files, I simply wish to "keep the most recent 5MB of entries".

A parameter such as "BarrelSize = 5MB" would describe the functionality I am looking for.

Is there any way of achieving this in the current implementation?  I can't see it.

Best regards to all.
Alan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I barrel a text logfile?

Jason LaFlair
Administrator
I don't think nlog can natively do this.  But in thinking about the idea, wouldn't that be a fairly large performance hit?  Append to the end of the file - then read to the top and start purging records?  Just a thought.
Loading...