Better logs for common ActionLog attribute paramters

This commit is contained in:
2014-01-23 13:59:15 -05:00
parent 30beccfc83
commit bb5dab48a0
6 changed files with 29 additions and 9 deletions
+3 -3
View File
@@ -13,12 +13,12 @@ namespace MileageTraker.Web.Attributes
var action = filterContext.RouteData.Values["action"].ToString();
var username = filterContext.HttpContext.User.Identity.Name;
var loggerName = string.Format("{0}Controller.{1}", controller, action);
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => i.Key + ": " + i.Value));
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => i.Key + ": {" + i.Value +"}"));
var hostAddress = "UserHostAddress: " + filterContext.HttpContext.Request.UserHostAddress;
var hostAddress = filterContext.HttpContext.Request.UserHostAddress;
log4net.LogManager.GetLogger(loggerName)
.InfoFormat("{0}, username: {1}, {2}", hostAddress, username, @params);
.InfoFormat("UserHostAddress: {0}, username: {1}, params: {{{2}}}", hostAddress, username, @params);
}
base.OnActionExecuting(filterContext);
}
+1 -6
View File
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Web;
using System.Web;
using System.Web.Mvc;
using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.Attributes
{