public static void LogCommon(ServiceLogger.LogLevel logLevel, string message, string customData, ServiceLogger.Component componentName = ServiceLogger.Component.None, string logFileType = "", string logFilePath = "") { if (ServiceLogger.serviceLog == null) { ServiceLogger.InitializeMtrtLog(); } if (ServiceLogger.ServiceLogLevel == ServiceLogger.LogLevel.None || logLevel < ServiceLogger.ServiceLogLevel) { return; } LogRowFormatter logRowFormatter = new LogRowFormatter(ServiceLogger.MessageTracingServiceLogSchema); logRowFormatter[1] = logLevel.ToString(); if (!string.IsNullOrEmpty(logFileType)) { string[] array = logFileType.Split(new char[] { '_' }); logRowFormatter[2] = array[0]; } if (!string.IsNullOrEmpty(logFilePath)) { logRowFormatter[3] = logFilePath; } logRowFormatter[4] = componentName.ToString(); logRowFormatter[5] = message; if (!string.IsNullOrEmpty(customData)) { logRowFormatter[6] = customData; } ServiceLogger.serviceLog.Append(logRowFormatter, 0); }
public static void ReadConfiguration() { string fileLocation = "d:\\MessageTracingServiceLogs"; ServiceLogger.ServiceLogLevel = ServiceLogger.LogLevel.Error; ServiceLogger.MaximumLogAge = TimeSpan.Parse("5.00:00:00"); ServiceLogger.MaximumLogDirectorySize = 500000000L; ServiceLogger.MaximumLogFileSize = 5000000L; try { fileLocation = ConfigurationManager.AppSettings["LogFilePath"].Trim(); ServiceLogger.ServiceLogLevel = (ServiceLogger.LogLevel)Convert.ToInt32(ConfigurationManager.AppSettings["LogLevel"]); ServiceLogger.MaximumLogAge = TimeSpan.Parse(ConfigurationManager.AppSettings["LogFileMaximumLogAge"]); ServiceLogger.MaximumLogDirectorySize = Convert.ToInt64(ConfigurationManager.AppSettings["LogFileMaximumLogDirectorySize"]); ServiceLogger.MaximumLogFileSize = Convert.ToInt64(ConfigurationManager.AppSettings["LogFileMaximumLogFileSize"]); } catch (Exception ex) { string text = string.Format("Fail to read config value, default values are used. The error is {0}", ex.ToString()); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_ConfigSettingNotFound, Thread.CurrentThread.Name, new object[] { text }); EventNotificationItem.Publish(ExchangeComponent.Name, "BadServiceLoggerConfig", null, text, ResultSeverityLevel.Error, false); if (RetryHelper.IsSystemFatal(ex)) { throw; } } finally { ServiceLogger.FileLocation = fileLocation; } }
public static void Log(ServiceLogger.LogLevel logLevel, ServiceLogger.Component componentName, LogUploaderEventLogConstants.Message message, string customData, string logFileType, string logFilePath) { ServiceLogger.LogCommon(logLevel, message.ToString(), customData, componentName, logFileType, logFilePath); }