For a few times I needed to add log4Net to projects I have been working on and occasionally I forget how to configure log4net in my project or website.
So, I’m writing it down and hope it can help others as well :)
1- Add reference to log4net
2- Create log4net.config.xml file under App_Data/Configuration/log4net directory. (or any directory you would like)
3- log4net.config.xml file should look like this – make sure to update the logging level
4- Define log4net config location in the web.config (or any other place if its not a web app). Do this by adding this line to the web config
5- Create a new file in your project of type global.asax. inside the Application_Start method add the below lines:
6 – Get an instance of the logger, by passign teh logger name. which you defined in the log4net config file