I have a Memory target and a File target in NLog set like this
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="true"
internalLogLevel="Off" internalLogFile="D:\temp\nlog-internal.log">
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
<target name="memory" xsi:type="Memory" layout="${level}|${time}|${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile" />
<logger name="*" minlevel="Info" writeTo="memory" />
</rules>
</nlog>
I get the MemoryTarget in the constructor like this
target = (MemoryTarget)NLog.LogManager.Configuration.FindTargetByName("memory");
After that I access the target's logs (still in the constructor) and there are a couple of messages. But after an N amount of messages NLog stops writing any messages to the memory target. Even more, if you try to get the target by name like I do in the beggining it returns null. Also after some time and fiddling around nlog falls with an OutOfMemoryException. The file target works fine though. How can you fix the MemoryTarget not writing logs and deleting itself?
UPD: I looked at the NLog internal debug log and noticed that at some point the targets get wiped. I have my main program with an NLog config and a dll with another one. But they are the same and should not conflict with each other. The internal log is here http://pastebin.com/M885xmBi