C# 使用NLog时执行错误
我想在执行代码时使用NLog记录异常,我已经安装了所需的文件并将其包括在内,在运行web服务时,我得到以下错误:C# 使用NLog时执行错误,c#,asp.net,nlog,C#,Asp.net,Nlog,我想在执行代码时使用NLog记录异常,我已经安装了所需的文件并将其包括在内,在运行web服务时,我得到以下错误: System.TypeInitializationException: The type initializer for 'Web_Service.Service1' threw an exception. --->System.IO.FileNotFoundException: Could not load file or assembly 'NLog, Version=2.
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>
获取有关自定义日志记录规则和输出的信息。
-->
System.IO.FileNotFoundException:
无法加载文件或程序集“NLog,版本=2.1.0.0,区域性=中性,PublicKeyToken=5120e14c03d0593c”
或者它的一个依赖项
系统找不到指定的文件
指示NLog dll缺失或版本不正确。检查输出中的dll文件是否存在,并且版本为2.1.0.0。NLog dll可能已更新,但可能尚未复制或部署到输出目录-因此出现错误
Nlog的正常dll文件名为
Nlog.dll
Nlog dll缺失或版本不正确。确保它在您的bin文件夹中。在我的bin中,我有NLog.Extended.dll,您能告诉我您是如何知道dll不正确或丢失的。您是否使用nuget软件包管理器安装了NLog软件包?您需要NLog.dll和NLog.Extended.dll。nlog extended dl仅在您想使用代码设置nlog配置时才需要。不是nlog.extended.dll
,似乎nlog.dll
丢失了对不起..愚蠢的问题..我是从网上下载的..无论如何..谢谢澄清..@Reshma使用NuGet-或手动下载-