I am using log4net for logging. My logging configuration is stored in a separate file.
Web.Config:ConfigSections
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
Specifying my config file in AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config", Watch = true)]
And when I initialize my LogManager, I get this error
"System.TypeLoadException"
message: Could not load type 'log4net.Config.Log4NetConfigurationSectionHlandler' from assembly 'Log4net'.
Yes it says "Log4NetConfigurationSectionHlandler'", it is not a typo
and later, this error
An error occurred creating the configuration section handler for log4net: Could not load type 'log4net.Config.Log4NetConfigurationSectionHlandler' from assembly 'Log4net'.
Edit: Tried Mauricio Scheffer's suggestion
got
log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
You can configure the log4net. config file to create log files. The file is located in the webroot\App_data directory of the installation.
log4net is one of three very popular frameworks for implementing log messages in your application (Serilog and NLog being the other two). log4net works with almost any version of . NET (including . NET Core).
Log4net is a logging utility for . NET applications. It's based on log4j, which is for Java applications. Log4net is highly configurable, so you can use it in many scenarios.
If you have your config in a separate log4net.config file you don't need the sectionHandler. Remove it.
You're also probably calling XmlConfigurator.Configure() somewhere in your code. Remove that as well.
Also see this question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With