public static void LogFailedMessage(object messageObj) { if (LogConfig.IsLoggingEnabled) { try { //log.SessionId = ApplicationContext.GetSessionId(); var dataProvider = new LoggingDataProvider(); var settings = new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Objects, }; var log = new Log() { Name = "FailedMessageItem", ServiceName = messageObj.GetType().Name, Request = JsonConvert.SerializeObject(messageObj, settings), }; if (LogConfig.IsLogAsyncEnabled) { Task.Factory.StartNew(() => dataProvider.SaveLog(log)); } else { dataProvider.SaveLog(log); } } catch (Exception ex) { File.AppendAllText("Logs.txt", "LogMessage method failed" + ex.ToString()); } } }
public static void LogMessage(Log log) { if (LogConfig.IsLoggingEnabled) { try { //log.SessionId = ApplicationContext.GetSessionId(); var dataProvider = new LoggingDataProvider(); if (LogConfig.IsLogAsyncEnabled) { Task.Factory.StartNew(() => dataProvider.SaveLog(log)); } else { dataProvider.SaveLog(log); } } catch (Exception ex) { File.AppendAllText("Logs.txt", "LogMessage method failed" + ex.ToString()); } } }