0
我有一個記憶目標和NLOG文件目標設定這樣NLOG內存目標錯誤
<?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>
我得到MemoryTarget在構造這樣
target = (MemoryTarget)NLog.LogManager.Configuration.FindTargetByName("memory");
之後,我訪問目標的日誌(仍在構造函數中),並且有幾條消息。但是在N個消息NLog停止將任何消息寫入內存目標之後。更重要的是,如果您嘗試按照名稱獲取目標,則返回null。同樣在經過一段時間後,圍繞nlog的擺弄會伴隨着OutOfMemoryException。文件目標雖然工作正常。如何修復MemoryTarget不寫日誌和刪除自己?
UPD:我看了一下NLog的內部調試日誌,發現在某些時候目標被擦掉了。我有我的主程序與NLog配置和一個DLL與另一個。但他們是一樣的,不應該相互衝突。內部日誌在這裏http://pastebin.com/M885xmBi
nlog用戶循環緩衝區還是存儲所有內容? – Thomas
@Thomas老實說,我不知道存儲的運行狀態。如果你需要這些信息,你應該檢查源代碼 –