這裏會把一些敏感的參數記錄下來,咱們須要屏蔽掉,如圖
less
咱們但願日誌裏面有當前登陸用戶的信息,如圖:
.net
tip:這裏用的是.net非.net core插件
ExceptionlessClient.Default.Configuration.AddDataExclusions("Password", "password", "Token", "token");
日誌
直接看代碼/註釋吧code
public class ExceptionlessConfig { public static void Configure() { //添加自定義插件 ExceptionlessClient.Default.Configuration.AddPlugin<ExceptionlessUserPlugin>(); //ExceptionlessClient.Default.Configuration.AddDataExclusions("Password", "password", "Token", "token"); } /// <summary> /// 日誌添加用戶信息 /// </summary> public class ExceptionlessUserPlugin : IEventPlugin { public void Run(EventPluginContext context) { IJsonSerializer serializer = context.Client.Configuration.Resolver.GetJsonSerializer(); UserInfo userInfo = 獲取當前登陸用戶信息; //設置用戶信息 AddUser(context, userInfo, serializer); } private static void AddUser(EventPluginContext context, UserInfo userInfo, IJsonSerializer serializer) { Exceptionless.Models.Data.UserInfo user = context.Event.GetUserIdentity(serializer); if (user != null || userInfo == null) return; //設置當前登陸用戶信息 context.Event.SetUserIdentity(new Exceptionless.Models.Data.UserInfo { //用戶ID Identity = userInfo.UserId, //用戶所在公司名--用戶名 Name = $"{userInfo.CompanyName}-{userInfo.UserName}", //擴展信息 Data = new Exceptionless.Models.DataDictionary(new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>("公司ID", userInfo.CompanyId), new KeyValuePair<string, object>("公司名稱", userInfo.ComanyName) }) }); } } }
固然須要在Global.cs
的Application_Start
方法中調用ExceptionlessConfig.Configure();
blog
context.Event
還有不少擴展,好比添加標籤、添加屬性...看需求了token
overip