public void Log(MethodBase method, object inputParameters, Exception ex, string error, int returnCode, int status) { try { var WalletLog = new Wallet_Logs { ApiCallerType = "api", ApiMethod = $"{method.ReflectedType.Name}.{method.Name}", AspNetUserId = "", Exception = (ex != null) ? JsonConvert.SerializeObject(ex) : error, Request = JsonConvert.SerializeObject(inputParameters), Status = (status == 1)? true:false, ReturnCode = returnCode, CreateDate = DateTime.Now, ProductId = 12 }; using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities())) { eWalletTransactionUnitOfWork.BeginTransaction().DoInsert(WalletLog).EndTransaction(); } } catch (Exception exe) { throw exe; } }
public static void LogWalletAPI(Wallet_Logs log) { try { var errorEvent = new LogEventInfo(LogLevel.Info, string.Empty, string.Empty); errorEvent.Properties["aspnetuser-id"] = log.AspNetUserId; errorEvent.Properties["product-id"] = log.ProductId; errorEvent.Properties["api-caller-type"] = log.ApiCallerType; errorEvent.Properties["api-method"] = log.ApiMethod; errorEvent.Properties["request"] = log.Request; errorEvent.Properties["exception"] = log.Exception; errorEvent.Properties["status"] = log.Status; errorEvent.Properties["return-code"] = log.ReturnCode; errorEvent.Properties["create-date"] = DateTime.Now; WalletLogger.Log(errorEvent); } catch (Exception) { //Ignore } }