在使用NLog在asp.net项目中发现,若是想单独配其配置文件的位置时没有像Log4Net的特性配置方案,可使其提供的 XmlLoggingConfiguration类来初始化:git
见:https://github.com/NLog/NLog/wiki/Configuration-filegithub
LogManager.Configuration = new XmlLoggingConfiguration("assets/someothername.config");
不过这种方法是不能在Web中使用的,你会看到奇怪的路径。asp.net
用下面这个应该就好了。.net
LogManager.Configuration = new XmlLoggingConfiguration(AppDomain.CurrentDomain.BaseDirectory + @"config\NLog.config", true);