Log4net does not write the log in the log file Log4net does not write the log in the log file asp.net asp.net

Log4net does not write the log in the log file


Do you call

log4net.Config.XmlConfigurator.Configure();

somewhere to make log4net read your configuration? E.g. in Global.asax:

void Application_Start(object sender, EventArgs e) {    // Code that runs on application startup    // Initialize log4net.    log4net.Config.XmlConfigurator.Configure();}


Use this FAQ page: Apache log4net Frequently Asked Questions

About 3/4 of the way down it tells you how to enable log4net debugging by using application tracing. This will tell you where your issue is.

The basics are:

<?xml version="1.0" encoding="utf-8" ?><configuration>    <appSettings>        <add key="log4net.Internal.Debug" value="true"/>    </appSettings></configuration>

And you see the trace in the standard output


As @AndreasPaulsson suggested, we need to configure it. I am doing the configuration in AssemblyInfo file. I specify the configuration file name here.

// Log4Net Configuration.[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]