How To Do Logging In MVC


Today, I want to talk about logging mechanism in We can do it in several ways. I use log4net to implement logging in my Mvc web projects.

First, we must add Log4net package from NuGet Package Manager to our ASP.NET MVC project as per the below screen.

After installing, you need to add this code to your Global.asax file .

Then we have to add log4net configuration to web.config.

After configuring, we will add logging as an attribute to use it in every classes we need. Add this class to your project.

And add this code to your AppManager.class

At the end we will add Logger attribute to our controllers we want to use.

You should have a look at my another post about Caching In Asp.Net MVC

 If you have question do not forget to write from the chat button next to it or from the comment.


You may also like...

1 Response

  1. March 11, 2019

    […] Output caching allows you to store the output of a particular controller action in memory. Then the engine can respond to future requests for the same action just by giving back the cached result. You should have a look at my another post about Logging In Asp.Net MVC […]

Leave a Reply

Your email address will not be published. Required fields are marked *