imlokesh imlokesh - 10 months ago 120
C# Question

How to clear MemoryTarget Logs in NLog?

I'm using a Memory Target for logging.

<target xsi:type="Memory" name="memLog" layout="${longdate} - ${message}" />

This is a log heavy application and eventually the log becomes very large and the application runs out of memory.

Is there any way to reset the
collection? It is a read-only property.

Answer Source

The MemoryTarget.Logs property implements IList. Why not just clear it like this: