在使用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);

  

相关文章:

  • 2021-09-22
  • 2021-04-24
  • 2022-12-23
  • 2021-11-28
  • 2021-04-17
  • 2022-12-23
  • 2021-09-13
  • 2021-12-08
猜你喜欢
  • 2022-12-23
  • 2021-10-20
  • 2021-08-08
  • 2021-09-01
  • 2022-01-16
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案