Better logs for common ActionLog attribute paramters
This commit is contained in:
@@ -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,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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user