log4net: How to read configuration from SQL Server database?

174 Views Asked by At

I'd like to store log4net.config in a sql server database but not in file. And Can log4net read the config from the sql server database? How to modify this?

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

There are 1 best solutions below

3
Mansur Kurtov On BEST ANSWER

Read your config data from database and by using log4net.Config.XmlConfigurator.Configure set log4net configurations during on start your app

var configData = DataBaseHelper.GetConfigDataFromDataBase();
using (var MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(configData))
{ 
     log4net.Config.XmlConfigurator.Configure(ms);
}