This project has moved and is read-only. For the latest updates, please go here.

log4net & File Not Found Error



When I start the project, I am getting the following URL: 'http://localhost:64450/Error.aspx?aspxerrorpath=/' , which says 'Apologies An unexpected error has occurred.' . I checked the Elmah log and see that there is a 404 - file not found error, but it doesn't tell me the file it's missing.

In addition, I am seeing an error in the Output window of VS when I compile, that states:

'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" />'

I tried manually adding that line to the Web.config, but the error persists...

Suggestions for these issues??

Thanks!! :)


Robinson_Derek wrote Mar 5, 2015 at 8:08 PM

Backup your project then try remove the loginet package and adding it again. Sounds mis-installed.

codeulike wrote Mar 5, 2015 at 9:31 PM

The 404 error you are getting, sounds like Visual Studio doesn't know which default page to open (that should be specified already in the web.config file)

Also the log4net error also sounds like Visual Studio hasn't found the setting in the web.config file that tells log4net to get its settings from logging.config.

In short, it sounds like there's something wrong with your web.config file - its either missing or been overwritten or something. It should look like this more or less:

Please check your web.config. Does it contain this :
        <add value="Home.aspx" />
And does it contain this?
<add key="log4net.Config" value="logging.config" />
also re: the 404 error: after you get it, try navigating to 'http://localhost:64450/Home.aspx' manually by typing in the URL. What happens?

DFWguy wrote Mar 6, 2015 at 9:30 PM

Thanks for the replies guys...

@Robinson_Derek: I tried removing the reference to log4net in my project, and manually added the .dll back to the project - This did not fix the error.

@Codeulike: I compared my web.config to the one you referenced, and they are almost identical. The only things I changed were for my server address. My config file does have the keys you mentioned above.

Also, when I run the site, it automatically goes to the error page, but if I direct it to Home.aspx, it will load the page without any obvious issues.

BTW: I am ALSO getting the error below in the VS Output Console, during runtime.

'iexplore.exe' (Script): Loaded 'Script Code (Windows Internet Explorer)'.
Exception was thrown at line 101, column 217 in http://localhost:64450/Scripts/jquery-1.4.4.min.js
0x800a139e - JavaScript runtime error: SyntaxError

Any ideas??

Thanks guys!! :)

Robinson_Derek wrote Mar 6, 2015 at 10:44 PM

What I intended to advise was use the nuget package manager to remove log4net and add it back in with the manager.
If you added it the hard way then remove it manually and use nuget to install it correctly.
Alternately, start a new project and add it with nuget and compare.
Best of luck

DFWguy wrote Mar 12, 2015 at 11:47 PM

Hey Derek,

I used the package manager to reinstall log4net, which finished successfully, but I am still getting the error in console, and the 'Apologies' error page on project launch.

I may just try to wipe out the project and start again... I'll post back if I find anything.

Please feel free to make more suggestions if you have them!

Thanks! :)