Log4jNet Logging in ASP.NET MVC

What to cover:

1. Install nugget package for Log4Net.

Step 1:

Create ASP.NET MVC project with any name you want. Right click on References

Step 2:

Select Manage NuGet Packages under References.

Step 3:

Select Browse tab and type Log4Net and Install and then click Ok. It will take some time.

Step 4:

After installing check on Installed tab and you will see Log4Net on installed section. Means It installed on your project.

Step 5:

As installing step 4 is complete now go to your project Global.asax file and add below entry on last of the list under Application_Start() method.

Step 6:

Now go to Web.config file which is last filer on project explorer as seen on below snaps and add below entry under <configuration> section.

Step 7:

Now again in Web.config add entry below entry under <configSections> section which is just after <configuration> from top.

Step 8:

Now all configurations have been done. Go to your class where code have been written. In my case below is code snippet.

--

--

Currently working as Full stack Java developer at Contour Software. Working on Java and IBM stack.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adil Abdullah

Currently working as Full stack Java developer at Contour Software. Working on Java and IBM stack.