I already have a db connection string in my web.config file. I scanned the log4net docs, but can\'t seem to find a way to use it within the log4net section of my web.config
the answers above all do not work. i got another solution for this, i tried and it worked:
private static void ConfigureLog4Net()
{
Hierarchy hierarchy = LogManager.GetRepository() as Hierarchy;
if(hierarchy != null && hierarchy.Configured)
{
foreach(IAppender appender in hierarchy.GetAppenders())
{
if(appender is AdoNetAppender)
{
var adoNetAppender = (AdoNetAppender)appender;
adoNetAppender.ConnectionString = ConfigurationManager.AppSettings["YOURCONNECTIONSTRINGKEY"].ToString();
adoNetAppender.ActivateOptions(); //Refresh AdoNetAppenders Settings
}
}
}
}
How i can use the connectionString of the current website for log4Net instead of configuring