public void AddLogMsgToSink() { try { var logMsg = _objMsgQ.GetLogMsg(); while (logMsg != null) { _objSumoLogger.WriteLog(logMsg.LogLevel, logMsg.LogMessage); logMsg = _objMsgQ.GetLogMsg(); } } catch (Exception ex) { try { _objSumoLogger.WriteLog(RoboticsLogLevelEnum.Error, LoggingMsgComposer.GetStringLogMsg(ex.Message + Environment.NewLine + ex.StackTrace, _serviceName)); } catch (Exception innerEx) { _objFileLogger.WriteLog(RoboticsLogLevelEnum.Error, LoggingMsgComposer.GetStringLogMsg(innerEx.Message + Environment.NewLine + innerEx.StackTrace, _serviceName)); } } }
static void Main(string[] args) { ReadGDSQueue objGDSQScanner = null; ///////Add settings in Azure table GDSServiceConfig objServiceConfig = new GDSServiceConfig(); ///////Validate Configuration settings IRoboticsLogger objFileLogger = RoboticsLoggerFactory.GetRoboticsLogger(RoboticsLoggerEnum.FileLogger, objServiceConfig.LocalLogPath, string.Empty, string.Empty); IMsgQProvider _objCloudLoggingQ = CloudObjectFactory.GetMsgQProvider(objServiceConfig.CloudProvider, objServiceConfig.CloudLoggingQName, objServiceConfig.ConnectionString); var logServiceStartMsg = LoggingMsgComposer.GetServiceStartLogMsg(objServiceConfig.ServiceName); _objCloudLoggingQ.AddMsgToLoggingQ(logServiceStartMsg); while (true) { try { ///////read settings from Azure table and referesh the settings objGDSQScanner = new ReadGDSQueue(objServiceConfig, objFileLogger, _objCloudLoggingQ); objGDSQScanner.ScanGDSQueue(); } catch (Exception ex) { try { LogMsg logMsg = LoggingMsgComposer.GetLogMsg(RoboticsLogLevelEnum.Error, "Parent Block: " + Constants.OUTER_CATCH_BLOCK_ERROR_MSG + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace, objServiceConfig.ServiceName, objServiceConfig.GalQNumber); _objCloudLoggingQ.AddMsgToLoggingQ(logMsg); } catch (Exception innerEx) { //LOG into local file try { objFileLogger.WriteLog(RoboticsLogLevelEnum.Error, LoggingMsgComposer.GetStringLogMsg("Parent Block: " + Constants.OUTER_CATCH_BLOCK_ERROR_MSG + Environment.NewLine + innerEx.Message + Environment.NewLine + innerEx.StackTrace, objServiceConfig.ServiceName, objServiceConfig.GalQNumber)); } catch { /* SUPPRESS EXCEPTTION TO RESTART THE FLOW AFTER DELAY */ } } } finally { objGDSQScanner = null; } Thread.Sleep(1000 * objServiceConfig.DelayInterval); } }
static void Main(string[] args) { LogDumper objLogDumper = null; LoggingConfig objLoggingConfig = new LoggingConfig(); IRoboticsLogger objFileLogger = RoboticsLoggerFactory.GetRoboticsLogger(RoboticsLoggerEnum.FileLogger, objLoggingConfig.LocalLogPath, string.Empty, string.Empty); var logServiceStartMsg = LoggingMsgComposer.GetServiceStartLogMsg(objLoggingConfig.ServiceName); //_objCloudLoggingQ.AddMsgToLoggingQ(logServiceStartMsg); while (true) { try { objLogDumper = new LogDumper(objLoggingConfig, objFileLogger); objLogDumper.AddLogMsgToSink(); } catch (Exception ex) { try { objFileLogger.WriteLog(RoboticsLogLevelEnum.Error, LoggingMsgComposer.GetStringLogMsg(ex.Message + Environment.NewLine + ex.StackTrace, objLoggingConfig.ServiceName)); } catch { } } finally { objLogDumper = null; } Thread.Sleep(1000 * objLoggingConfig.DelayInterval); } }