static void Main(string[] args) { var fd = GetFlogDetail("starting applicaction", null); Flogger.WriteDiagnostic(fd); var tracker = new PerfTracker("FloggingConsoloe_execution", fd.UserId, fd.UserName, fd.Location, fd.Product, fd.Layer); try { var ex = new Exception("Something bad has happened"); ex.Data.Add("input param", "nothing to see here"); throw ex; } catch (Exception ex) { fd = GetFlogDetail("", ex); Flogger.WriteError(fd); } fd = GetFlogDetail("use flogging detail", null); Flogger.WriteUsage(fd); fd = GetFlogDetail("stopping app", null); Flogger.WriteDiagnostic(fd); tracker.Stop(); }
public static void LogWebUsage(string product, string layer, string activityName, Dictionary <string, object> additionalInfo = null) { string userId, userName, location; var webInfo = GetWebFloggingData(out userId, out userName, out location); if (additionalInfo != null) { foreach (var key in additionalInfo.Keys) { webInfo.Add($"Info-{key}", additionalInfo[key]); } } var usageInfo = new FlogDetail() { Product = product, Layer = layer, Location = location, UserId = userId, UserName = userName, Hostname = Environment.MachineName, CorrelationId = HttpContext.Current.Session.SessionID, Message = activityName, AdditionalInfo = webInfo }; Flogger.WriteUsage(usageInfo); }
static void Main(string[] args) { // diagnostic var flogDetail = GetFlogDetail("starting application", null); Flogger.WriteDiagnostic(flogDetail); // perf tracker var tracker = new PerfTracker("Flogger.Console Execution", "", flogDetail.UserName, flogDetail.Location, flogDetail.Product, flogDetail.Layer); // error try { var ex = new Exception("Something bad has happened"); ex.Data.Add("input param", "nothing to see here..."); throw ex; } catch (Exception ex) { flogDetail = GetFlogDetail("", ex); Flogger.WriteError(flogDetail); } flogDetail = GetFlogDetail("Flogging.Console Usage", null); Flogger.WriteUsage(flogDetail); flogDetail = GetFlogDetail("Stopping Flogging.Console", null); Flogger.WriteDiagnostic(flogDetail); tracker.Stop(); }
public static void LogWebUsage(string product, string layer, string activityName) { string userId, userName, location; var webInfo = GetWebFloggingData(out userId, out userName, out location); var usageInfo = new FlogInfo() { Product = product, Layer = layer, Location = location, UserId = userId, UserName = userName, Hostname = Environment.MachineName, CorrelationId = HttpContext.Current.Session.SessionID, Message = activityName, AdditionalInfo = webInfo }; Flogger.WriteUsage(usageInfo); }
public void Write([FromBody] FlogDetail logEntry) { Flogger.WriteUsage(logEntry); }
static void Main(string[] args) { var fd = GetFlogDetail("starting application", null); Flogger.WriteDiagnostic(fd); var tracker = new PerfTracker("FloggerConsole_Execution", "", fd.UserName, fd.Location, fd.Product, fd.Layer); //try //{ // var ex = new Exception("Something bad has happened!"); // ex.Data.Add("input param", "nothing to see here"); // throw ex; //} //catch (Exception ex) //{ // fd = GetFlogDetail("", ex); // Flogger.WriteError(fd); //} var connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); using (var db = new SqlConnection(connStr)) { db.Open(); try { //RAW ADO.NET //var rawAdoSp = new SqlCommand("CreateNewCustomer", db) //{ // CommandType = System.Data.CommandType.StoredProcedure //}; //rawAdoSp.Parameters.Add(new SqlParameter("@Name", "waytoolongforitsowngood")); //rawAdoSp.Parameters.Add(new SqlParameter("@TotalPurchases", 12000)); //rawAdoSp.Parameters.Add(new SqlParameter("@TotalReturns", 100.50M)); //rawAdoSp.ExecuteNonQuery(); var sp = new Sproc(db, "CreateNewCustomer"); sp.SetParam("@Name", "waytoolongforitsowngood"); sp.SetParam("@TotalPurchases", 12000); sp.SetParam("@TotalReturns", 100.50M); sp.ExecNonQuery(); } catch (Exception ex) { var efd = GetFlogDetail("", ex); Flogger.WriteError(efd); } try { // Dapper //db.Execute("CreateNewCustomer", new //{ // Name = "dappernametoolongtowork", // TotalPurchases = 12000, // TotalReturns = 100.50M //}, commandType: System.Data.CommandType.StoredProcedure); // Wrapped Dapper db.DapperProcNonQuery("CreateNewCustomer", new { Name = "dappernametoolongtowork", TotalPurchases = 12000, TotalReturns = 100.50M }); } catch (Exception ex) { var efd = GetFlogDetail("", ex); Flogger.WriteError(efd); } } var ctx = new CustomerDbContext(); try { // Entity Framework var name = new SqlParameter("@Name", "waytoolongforitsowngood"); var totalPurchases = new SqlParameter("@TotalPurchases", 12000); var totalReturns = new SqlParameter("@TotalReturns", 100.50M); ctx.Database.ExecuteSqlCommand("EXEC dbo.CreateNewCustomer @Name, @TotalPurchases, @TotalReturns", name, totalPurchases, totalReturns); } catch (Exception ex) { var efd = GetFlogDetail("", ex); Flogger.WriteError(efd); } var customers = ctx.Customers.ToList(); fd = GetFlogDetail($"{customers.Count} customers in the database", null); Flogger.WriteDiagnostic(fd); fd = GetFlogDetail("used flogging console", null); Flogger.WriteUsage(fd); fd = GetFlogDetail("stopping app", null); Flogger.WriteDiagnostic(fd); tracker.Stop(); }