imlokesh imlokesh - 2 years ago 292
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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download