public static void Warn(NCacheLog.LoggerNames loggerName, String module, String message) { string name = loggerName.ToString(); ; if (loggerName != LoggerNames.ClientLogs) name = LoggingInformation.GetStaticLoggerName(loggerName.ToString()); Warn(name, module, message); }
public static bool IsDebugEnabled(NCacheLog.LoggerNames loggerEnum) { #region isEnabledLogic string temp = LoggingInformation.GetStaticLoggerName(loggerEnum.ToString()); if (temp != null && temp.Length > 0) { string loggerName = LoggingInformation.GetLoggerName(temp); if (loggerName != null && loggerName.Length > 0) { log4net.ILog log = log4net.LogManager.GetLogger(loggerName); return log.IsDebugEnabled; } else { NCacheLog.LogLoggingError("loggerName != null && loggerName.Length > 0"); } } return false; #endregion }
public static void CriticalInfo(NCacheLog.LoggerNames loggerName, string message) { string name = loggerName.ToString(); ; if (loggerName != LoggerNames.ClientLogs) name = LoggingInformation.GetStaticLoggerName(loggerName.ToString()); CriticalInfo(name, message); }
/// <summary> /// intitializes Known name based log files /// </summary> /// <param name="loggerName">Enum of Known loggerNames</param> /// <param name="cacheName">cacheName use the other override</param> public static void Initialize(NCacheLog.LoggerNames loggerNameEnum, string cacheName) { lock (lockObj) { MemoryStream logStream = new MemoryStream(log4netXML); log4net.Config.XmlConfigurator.Configure(logStream); string logName = loggerNameEnum.ToString(); string filename = logName; if (loggerNameEnum == NCacheLog.LoggerNames.ClientLogs && (cacheName != null && cacheName.Length > 0)) { filename = filename + "." + cacheName + "." + System.Diagnostics.Process.GetCurrentProcess().Id; // changing the name here will invalidate static log checks automatically since LoggerName == ClientLogs logName = cacheName + System.Diagnostics.Process.GetCurrentProcess().Id; } else { if (cacheName != null && cacheName.Length > 0) filename = cacheName; } //If Logger is already present, can either be a cache or Client if (LoggingInformation.GetLoggerName(logName) != null) { if (loggerNameEnum == NCacheLog.LoggerNames.ClientLogs) return; // clientLogs alread initiated else { if (LoggingInformation.GetStaticLoggerName(logName) != null) return; // Log already initiated else { logName = logName + DateTime.Now; } } } else { if (loggerNameEnum != NCacheLog.LoggerNames.ClientLogs) { if (LoggingInformation.GetStaticLoggerName(logName) != null) return; // Log already initiated else { logName = logName + DateTime.Now; } } } filename = filename + "." + Environment.MachineName.ToLower() + "." + DateTime.Now.ToString("dd-MM-yy HH-mm-ss") + @".logs.txt"; string filepath = ""; if (!DirectoryUtil.SearchGlobalDirectory("log-files", false, out filepath)) { try { DirectoryUtil.SearchLocalDirectory("log-files", true, out filepath); } catch (Exception ex) { throw new Exception("Unable to initialize the log file", ex); } } try { filepath = Path.Combine(filepath, loggerNameEnum.ToString()); if (!Directory.Exists(filepath)) Directory.CreateDirectory(filepath); filepath = Path.Combine(filepath, filename); LoggingInformation.cacheLogger.Add(logName, logName); if (loggerNameEnum != NCacheLog.LoggerNames.ClientLogs) { LoggingInformation.staticCacheLogger.Add(loggerNameEnum.ToString(), logName); } SetLevel(logName, NCacheLog.Level.OFF.ToString()); AddAppender(logName, CreateBufferAppender(logName, filepath)); } catch (Exception) { throw; } } }