我無法使用NLog寫入事件日誌。我已經能夠寫入控制檯和文件。我在NLog中打開了異常,並且沒有收到NLog的反饋。NLog:無法寫入事件日誌
這裏是我的NLog.config:
<?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"
throwExceptions="true">
<targets>
<target name="console" xsi:type="Console" layout="${message}" />
<target xsi:type="EventLog" name="eventlog" layout="${message}" log="Application" source="aaaTest"/>
<target xsi:type="File" fileName="log.txt" name="file"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="eventlog,console,file" />
</rules>
</nlog>
在事件查看器,我在看 「事件查看器(本地)」 - > 「Windows日誌」> 「應用程序」。但是,我沒有在日誌中看到「aaaTest」(我定義的源)的實例。
如果我跑我的應用程序管轄,日誌消息將正確地在事件日誌中顯示出來。我正在使用Windows 7.除非將我的應用程序作爲管理運行,否則沒有其他方式可以寫入事件日誌嗎? (我偶然發現了這篇文章,它讓我有機會嘗試以管理身份運行:http://webcache.googleusercontent.com/search?q=cache:8pYpa9wBFTEJ:connect.microsoft.com/VisualStudio/feedback/details/509224/security -exception-trying-access-application-event-log + my.application.log + securityexception&cd = 1&hl = en&ct = clnk&gl = us&client = firefox -a) – sparks 2010-07-01 21:34:57