简体   繁体   English

C#DLL-为Common.Logging(Log4Net)加载单独的app.config文件

[英]C# DLL - Loading seperate app.config file for Common.Logging (Log4Net)

I am busy working on a C# library and I would like to make use of the Common.Logging with Log4Net, however, it looks for in the host applications app.config file for respective libraries settings. 我正在忙于C#库,我想使用Common.Logging与Log4Net,但是,它将在主机应用程序的app.config文件中查找相应的库设置。

Is there anyway of telling Common.Logging to look at a different config file? 无论如何,告诉Common.Logging查看不同的配置文件?

you could execute this code once on applicatin startup: 您可以在应用启动时执行以下代码一次:

XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

you may add this to AssemblyInfo.cs with the same result. 您可以将其添加到AssemblyInfo.cs ,结果相同。

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM