I am trying to log error using log4net in asp.net MVC5 c#.
For test purpose, I have configured log4net in application_start and initialize logger and log error from home controller. For some reason, log4net only logs error for the first time when I start the application. When I navigate away from homecontroller and come back to home controller again, no error is logged. I have put my logging code in HomeController index. When debugged using breakpoint, the logging code is reachable but the log is not recorded.
Am I missing anything?
Here is my log4net configuration.
Configured log4net in Global.asax Application_Start() as
log4net.Config.XmlConfigurator.Configure();In my home controller index (For Testing), I am logging error as
var logger = log4net.LogManager.GetLogger(this.GetType()); Random rnd = new Random(); int rndint = rnd.Next(52); logger.Error(rndint.ToString());My config file is using standard log4net
AdoNetAppenderwith buffer size=100 and level is set toWARN