user557168
user557168

Reputation: 161

Configuration system failed to initialize in log4net

I am getting this exception "Configuration system failed to initialize" while reading connection string from app_config in window application

string con = ConfigurationSettings.AppSettings["ConnectionString"].ToString();

on this line after entering following lines

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

in AssemblyInfo.cs. if i remove this line from Assemblyinfo.cs then there is no exception i am adding this assembly for logging purpose

Upvotes: 2

Views: 6867

Answers (2)

Fawad Ali Siddiqi
Fawad Ali Siddiqi

Reputation: 421

I am not sure but if you are using VSTO for MS Office Add-In Development than below post might help you.

Why is log4net not recognized in configuration file?

You need to add log4net also in the section block

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> 
</configSections>

Upvotes: 9

Ross Patterson
Ross Patterson

Reputation: 9570

This is a .NET problem, not a log4net problem. Your app.config file isn't being loaded. See Configuration System Failed to Initialize for a good answer to the real problem.

Upvotes: 0

Related Questions