我想在执行我的代码时使用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