i'm a .net/c# noob (long-time servlet/java developer)
i need to add logging to my mvc application. i want it to be fairly cheap performance-wise, and simple to configure.
what i would initially like to do is log each incoming controller action. it occurred to me that there might be a single-point-of-entry so i don't have to add a line of code to every controller's action methods.
the way i see it, i can either add a [LogRequest] attribute to the controller (in my case, a base controller) and then implement a
public class LogsRequestsAttribute : ActionFilterAttribute, IActionFilter
{
void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
{ ... }
}
class to handle the logrequest attribute.
or
i could just override the base controller as per:
public class BaseController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
// perform some action here
}
}
and inherit all my controllers from BaseController.
in terms of performance, which would be quicker?
also, in terms of performance, i am considering putting the actual logging method call in a non-blocking thread that runs once and dies. any pitfalls with this approach? the goal is to let the app proceed and not wait around for the logging method to finish it's task.