Search code examples
c#asp.net-mvcelmahelmah.mvc

Is there a setting that I can configure ELMAH to automatically track user and CRUD activity?


I am using ELMAH.MVC for error logging but I was wondering if I could also do the same for logging user movement(what pages the user visits, information lookups, etc) and Create, Read, Update, Delete activity within the application. Is this possible out of the box or via web.config setting or do I have to do it programatically within the controller?


Solution

  • You would need to add some code in order to do this. You can implement an action filter for MVC and use the ErrorSignal class from ELMAH to store custom messages:

    ErrorSignal.FromCurrentContext().Raise(new Exception("User navigation to ..."));
    

    With that said, I wouldn't recommend you to use ELMAH for log messages like this. ELMAH is for logging exceptions and nothing else really. Maybe you should take a look at a logging framework like Serilog, NLog, or Microsoft.Extensions.Logging and store this kind of logging somewhere else?