错误执行,同时使用NLOG [英] Error in execution while using NLog

查看:143
本文介绍了错误执行,同时使用NLOG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想利用NLOG,同时执行我的code登录例外,我已经安装了所需文件,包括它,我跑我的web服务的那一刻,我得到以下错误,

  System.TypeInitializationException:该类型初始化
Web_Service.Service1引发了异常。 ---> System.IO.FileNotFoundException:找不到
无法加载文件或程序集NLOG,版本= 2.1.0.0,文化=中性公钥= 5120e14c03d0593c
它依赖或1。该系统找不到指定的文件。
在Web_Service.Service1..cctor()
---内部异常堆栈跟踪的结尾---

和我在我的code。使用NLOG如下,

 私有静态记录器记录= LogManager.GetCurrentClassLogger();

任何一个可以告诉我,我错了。

下面是我nlog.config文件

 有关定制日志记录规则和输出信息。
   - >
  <目标的xsi:type =文件NAME =文件文件名=$ {BASEDIR} /日志/ $ {} shortdate .LOG
         布局=
  ------------ $ {的longdate} $ {大写:$ {}级} $ {}消息------------- $ {}换行符
 $ {}换行符
调用点:$ {调用点} $ {}换行符
异常类型:$ {异常:格式=类型} $ {}换行符
异常消息:$ {异常:格式=消息} $ {}换行符
堆栈跟踪:$ {异常:格式=堆栈跟踪} $ {}换行符
附加信息:$ {消息} $ {}换行符
          />
< /目标>
<规则与GT;
  <! - 在这里添加您的日志记录规则 - >
   <记录器名称=*定义的MinLevel =跟踪中的writeTo =文件/>
   <记录器名称=*定义的MinLevel =信息的writeTo =文件/>
< /规则>


解决方案

  

System.IO.FileNotFoundException:找不到


  
  

无法加载文件或程序集NLOG,版本= 2.1.0.0,文化=中性公钥= 5120e14c03d0593c
  它依赖或1。


  
  

该系统找不到指定的文件。


指示NLOG DLL文件丢失或不正确的版本。检查输出的DLL文件是present,而且是2.1.0.0版本。 NLOG DLL可能被更新,但它可能不被复制或部署到输出目录 - 因此错误

有关NLOG正常的DLL文件名是 NLog.dll

I want to make use of NLog to log the exception while executing my code, I have installed the required files and included it, the moment I run my web service, I get following error,

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 ---

and I am using NLog in my code as follows,

private static Logger logger = LogManager.GetCurrentClassLogger();,

Can any one tell me where I am wrong.

below is my nlog.config file

  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:

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.

Indicates that the NLog dll is missing or not the correct version. Check that the dll file in the output is present, and is version 2.1.0.0. NLog dll may been updated but it may not have been copied or deployed to the output directory - hence the error.

The normal dll filename for Nlog is NLog.dll.

这篇关于错误执行,同时使用NLOG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆