我可以有多个log4net配置文件吗?
问题描述:
对于同一个程序,我可以有多个log4netconfigurations吗?类似于Spring的<import>
元件的功能将是最佳的。这里的想法是让多个程序有自己的log4net配置,并且共享一个包含共享错误日志的*log4net配置文件(这样定义不会重复)。或者,这种功能可能与.NET Common Logging?我可以有多个log4net配置文件吗?
答
您可以通过使用名为库实现这一目标,我认为
log4net.LogManager.CreateRepository(repositoryName)
log4net.Config.XmlConfigurator.Configure(repositoryName, configFile)
然后用
LogManager.GetLogger(repositoryName,loggerName)
就可以得到相应的记录。
答
不是开箱即用的。您必须实现将不同配置文件合并到单个XmlNode中,并将其传递给log4net XmlConfiguratot。
一个例子可以在这里找到:http://www.kopf.com.br/kaplof/using-multiple-configuration-files-with-log4net
这并不能真正解决我的问题。我不想要多组配置,我想要一组恰好在多个文件中的配置。 –