开发者

Can I have multiple log4net configuration files?

Can I have multiple log4net configurations for the same program? Functionality similar to Spring's <import> element would be optimal. The idea here would to hav开发者_如何学JAVAe multiple programs that have their own log4net configuration, as well as sharing a central log4net configuration file containing a shared error log (so that definition isn't repeated). Alternatively is this functionality possible with .NET Common Logging?


Related: log4net - configure using multiple configuration files


you can achieve this by using named repositories i think

log4net.LogManager.CreateRepository(repositoryName)
log4net.Config.XmlConfigurator.Configure(repositoryName, configFile)

then by using

LogManager.GetLogger(repositoryName,loggerName)

you can get the corresponding logger.


Not out-of-the-box. You must implement yourself the merging of different config files into a single XmlNode and pass this to log4net XmlConfiguratot.

An example is to be found here: http://www.kopf.com.br/kaplof/using-multiple-configuration-files-with-log4net

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜