static void Main(string[] args) { var loggerConfiguration = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .MinimumLevel.Override("System", LogEventLevel.Error) .Enrich.FromLogContext() .Enrich.WithMachineName() .Enrich.WithProperty("Domain", "MyTeamRS") .Enrich.WithProperty("Application", "MyProjectRS") .WriteTo.Seq("http://localhost:5341") .WriteTo.Console(); Log.Logger = loggerConfiguration.CreateLogger(); //RestClientAutologConfiguration restClientAutologConfiguration = new RestClientAutologConfiguration() //{ // LoggerConfiguration = loggerConfiguration //}; RestClientAutolog client = new RestClientAutolog("http://pruu.herokuapp.com"); client.AddDefaultHeader("DefaultHeaderTest", "SomeValue"); client.Configuration.RequestJsonBlacklist = new string[] { "*password" }; RestRequest request = new RestRequest("dump/{name}", Method.POST); request.AddHeader("RequestCustomHeader", "SomeValue2"); request.AddHeader("RequestCustomHeader", "SomeValue3"); request.AddHeader("RequestKey", "keykeykey"); request.AddUrlSegment("name", "RestsharpAutoLog"); request.AddQueryParameter("CustomQuery", "SomeValue3"); request.AddQueryParameter("CustomQuery", "SomeValue2"); request.AddQueryParameter("CustomQuery1", "SomeValue1"); request.AddQueryParameter("CustomQuery2", ""); request.AddQueryParameter("CustomQuery3", null); request.AddJsonBody(new { TestOne = 123, TestTwo = "SomeValueBody", Password = "******", Test = new { Password = 123 } }); var response = client.Execute(request); Console.ReadKey(); }
public static IRestClient AddLogAdditionalInfo(this IRestClient restClient, string key, string value) { if (!(restClient is RestClientAutolog)) { return(restClient); } RestClientAutolog restClientAutolog = (RestClientAutolog)restClient; restClientAutolog.AddDefaultHeader(key, value); restClientAutolog.AdditionalProperties[key] = value; return(restClientAutolog); }
/// <summary> /// Get Client /// </summary> /// <param name="fullUri"></param> /// <returns></returns> private RestClientAutolog GetClient(string fullUri) { var client = new RestClientAutolog(); client.BaseUrl = new Uri(fullUri); client.AddLogAdditionalInfo("RequestKey", this.Configuration.RequestKey); client.AddLogAdditionalInfo("AccountId", this.Configuration.MerchantId); client.AddLogAdditionalInfo("MerchantId", this.Configuration.MerchantId); client.Configuration.JsonBlacklist = new string[] { "*card.token", "*card.exp_year", "*card.exp_month", "*card.cvv", "*card.number", "token", "exp_year", "exp_month", "cvv", "number" }; client.AddDefaultHeader("User-Agent", "Mundipagg Dotnet SDK"); client.AddNewtonsoftResponseHandler(NewtonsoftRestsharpJsonSerializer); client.Timeout = this.Configuration.Timeout; return(client); }