-
Notifications
You must be signed in to change notification settings - Fork 165
Log HTTP calls
Julian Verdurmen edited this page Jun 9, 2016
·
4 revisions
How to log all http calls with ASP.NET MVC
public class LogHttpRequestAttribute : ActionFilterAttribute
{
private static Logger _logger = LogManager.GetCurrentClassLogger();
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
_logger.Debug("action executing");
base.OnActionExecuting(filterContext);
}
}
usage:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
// Register global filter
GlobalFilters.Filters.Add(new LogHttpRequestAttribute ());
}
For request URL, use for example ${aspnet-request:serverVariable=HTTP_URL}
, See wiki
For general docs, check https://github.com/NLog/NLog/wiki