how to add configuration for log4net (or any other 3rd party library) in ASP.NET 5.0 how to add configuration for log4net (or any other 3rd party library) in ASP.NET 5.0 json json

how to add configuration for log4net (or any other 3rd party library) in ASP.NET 5.0


Recently I had the same problem with log4net. I managed to do it working as following:

Create log4net.xml file containing the configuration section for log4net

<?xml version="1.0" encoding="utf-8" ?><log4net>...</log4net>

You can put the file in the project root folder.

And in the Startup.Startup() method you can configure the log4net providing the xml as a configuration:

public Startup(IApplicationEnvironment appEnv){    // ...     XmlConfigurator.Configure(new FileInfo(Path.Combine(appEnv.ApplicationBasePath, "log4net.xml")));}

I hope this helps.


Current versions of log4net don't support Json projects, so the config needs to be in a separate xml file.