我可以使用NLog記錄窗口事件源。使用NLog記錄到特定事件源
但我想要的是寫一個特定的事件源:如:MyEventSource
我的配置是:
<?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">
<targets>
<target name="eventlog" xsi:type="EventLog" log="MyEventSource" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="eventlog" />
</rules>
</nlog>
那麼當我嘗試登錄參選,創建MyEventSource但日誌消息寫入通用窗口[7]應用程序事件源而不是MyEventSource。
更新:
<target name="eventlog" xsi:type="EventLog"
layout="${message}" log="custom_log" source="custom_source" />
沒有什麼區別
沒有diffrence..I不登錄到「custom_log」 ...... – Novalis 2012-01-31 10:28:26
在這種情況下,你應該使用源屬性,而不是日誌:<目標名稱=「事件日誌」 xsi:type =「EventLog」source =「MyEventSource」/>如果它不起作用,請嘗試更改源名稱--nlog會將其配置爲應用程序日誌。 – kolbasov 2012-01-31 10:33:10
「使用」是什麼意思?只是配置文件...如果我沒有設置日誌,它不會創建一個名爲custom_log的自定義事件源... – Novalis 2012-01-31 10:37:48