我想在執行我的代碼時使用NLog記錄異常,我安裝了所需的文件並將其包含在內,當我運行我的web服務時,出現以下錯誤,使用NLog執行時出錯
System.TypeInitializationException: The type initializer for
'Web_Service.Service1' threw an exception. --->System.IO.FileNotFoundException:
Could not load file or assembly 'NLog, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'
or one of its dependencies. The system cannot find the file specified.
at Web_Service.Service1..cctor()
--- End of inner exception stack trace ---
,我在我的代碼使用NLOG如下,
private static Logger logger = LogManager.GetCurrentClassLogger();,
任何一個可以告訴我,我錯了。
下面是我nlog.config文件
for information on customizing logging rules and outputs.
-->
<target xsi:type="File" name ="file" fileName="${basedir}/logs/${shortdate}.log"
layout="
------------${longdate} ${uppercase:${level}} ${message}-------------${newline}
${newline}
Call Site: ${callsite}${newline}
Exception Type: ${exception:format=Type}${newline}
Exception Message: ${exception:format=Message}${newline}
Stack Trace: ${exception:format=StackTrace}${newline}
Additional Info: ${message}${newline}"
/>
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="file" />
<logger name ="*" minlevel ="Info" writeTo ="file"/>
</rules>
NLog dll缺失或不正確的版本。確保它在您的bin文件夾中。 – Kami
在我的箱子裏我有NLog.Extended.dll,你能告訴我你怎麼知道該DLL不正確或丟失。 – Reshma
您是否使用nuget包管理器來安裝nlog包? – th1rdey3