码迷,mamicode.com
首页 > Web开发 > 详细

配置Asp.Net Web项目NLog配置文件的位置

时间:2017-03-22 18:57:27      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:targe   assets   highlight   配置   asp   dir   sha   blank   sharp   

在使用NLog在asp.net项目中发现,如果想单独配其配置文件的位置时没有像Log4Net的特性配置方案,可以使其提供的 XmlLoggingConfiguration类来初始化:

见:https://github.com/NLog/NLog/wiki/Configuration-file

LogManager.Configuration = new XmlLoggingConfiguration("assets/someothername.config");

  

不过这种方法是不能在Web中使用的,你会看到奇怪的路径。

用下面这个应该就行了。

LogManager.Configuration = new XmlLoggingConfiguration(AppDomain.CurrentDomain.BaseDirectory + @"config\NLog.config", true);

  

配置Asp.Net Web项目NLog配置文件的位置

标签:targe   assets   highlight   配置   asp   dir   sha   blank   sharp   

原文地址:http://www.cnblogs.com/atwind/p/6601150.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!