1

I'm trying to setup Audit.NET's Audit.MVC extension, but it's not creating log files. I'm thinking im missing something obvious here, here's what i've got, i can't find any more documentation on what i should be doing.

Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EE.Controllers;
using EE.CustomFilters;
using EE.DAL;
using EE.Models;
using EE.ViewModels;
using EE.ViewModels.AdminViewModels;

namespace EE.Controllers
{

public class AdminController : BaseController
{
  [Audit] 
  public ActionResult Index()
  { 
   //do stuff
  }
}

Global.asax.cs

protected void Application_Start()
{
  //other stuff

  Audit.Core.Configuration.Setup()
               .UseFileLogProvider(_ => _
                   .Directory(@"C:\Logs"));
}

(or Startup.cs i've tried both)

public void Configuration(IAppBuilder app)
{
      Audit.Core.Configuration.Setup()
           .UseFileLogProvider(_ => _
               .Directory(@"C:\Logs"));
}

Is there anything else i need to do? Any ideas?

loveforfire33
  • 1,090
  • 3
  • 25
  • 46
  • 1
    Which framework version do you target? From which class your Controller is inheriting? – thepirat000 Oct 25 '18 at 16:15
  • @thepirat000 .Net 4.7.1, the controller inherits from a base controller, i've edited the OP – loveforfire33 Oct 25 '18 at 16:29
  • And I guess your `BaseController` inherits from `System.Web.Mvc.Controller`. If that's the case, everything looks fine. You can open a new issue [here](https://github.com/thepirat000/Audit.NET/issues/new/choose) – thepirat000 Oct 25 '18 at 19:47
  • @thepirat000 Yeah it does, just want to make sure i'm trying to set this up in the right way before i open an issue. Please see the edits above. – loveforfire33 Oct 25 '18 at 20:00
  • Do you hit the `Audit.Core.Configuration.Setup()` call if you put a breakpoint there? – thepirat000 Oct 25 '18 at 20:36
  • No, i was unsure if it was supposed to be hit (im still learning a lot of this) – loveforfire33 Oct 25 '18 at 22:05
  • Yes, the `Setup()` needs to run before any action. `Application_Start` should be fine. – thepirat000 Oct 26 '18 at 01:40
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/182556/discussion-between-thepirat000-and-loveforfire33). – thepirat000 Oct 26 '18 at 05:18

0 Answers0