public static bool IsDebugEnabled(string cacheName) { #region isEnabledLogic if (cacheName == null || cacheName == string.Empty) { NCacheLog.LogLoggingError("Cache Name is null"); return(false); } string loggerName = LoggingInformation.GetLoggerName(cacheName); if (loggerName != null && loggerName.Length > 0) { log4net.ILog log = log4net.LogManager.GetLogger(loggerName); return(log.IsInfoEnabled); } else { NCacheLog.LogLoggingError("loggerName != null && loggerName.Length > 0"); } return(false); #endregion return(true); }
public static bool[] ReadClientConfig(out int bufferAppender) { try { string EnableLogs = System.Configuration.ConfigurationManager.AppSettings["EnableNCWebLogs"]; string EnableDetailedLogs = System.Configuration.ConfigurationManager.AppSettings["EnableDetailedNCWebLogs"]; string BufferSize = System.Configuration.ConfigurationManager.AppSettings["BufferSize"]; try { if (BufferSize != null) { bufferAppender = Convert.ToInt32(BufferSize); } else { bufferAppender = bufferDefaultSize; } } catch (Exception) { bufferAppender = bufferDefaultSize; } if (EnableDetailedLogs == null && EnableLogs == null) { return(new bool[2] { false, false }); } else if (EnableDetailedLogs != null && EnableLogs == null) { return(new bool[2] { false, Convert.ToBoolean(EnableDetailedLogs) }); } else if (EnableDetailedLogs == null && EnableLogs != null) { return(new bool[2] { Convert.ToBoolean(EnableLogs), false }); } else { return(new bool[2] { Convert.ToBoolean(EnableLogs), Convert.ToBoolean(EnableDetailedLogs) }); } } catch (Exception ex) { bufferAppender = bufferDefaultSize; return(new bool[2] { false, false }); NCacheLog.LogLoggingError(ex.Message); } }
internal static string GetStaticLoggerName(string name) { if (name == null || name == string.Empty) { NCacheLog.LogLoggingError("CacheName Empty"); return(null); } else { return((string)staticCacheLogger[name]); } }
/// <summary> /// Returns the logger Name w.r.t the cache Name /// </summary> /// <param name="cacheName">CacheName to which the loggername is associated</param> /// <returns>returns the logger Name, if not found null is returned</returns> internal static string GetLoggerName(string cacheName) { if (cacheName == null || cacheName == string.Empty) { NCacheLog.LogLoggingError("CacheName Empty"); return(null); } else { return((string)cacheLogger[cacheName]); } }
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 Warn(string cacheName, string message) { if (cacheName == null || cacheName == string.Empty) { NCacheLog.LogLoggingError("Cache Name is null"); return; } string loggerName = LoggingInformation.GetLoggerName(cacheName); if (loggerName != null && loggerName.Length > 0) { log4net.ILog log = log4net.LogManager.GetLogger(loggerName); if (message.Contains(Environment.NewLine)) { message = message + "\r\n"; } log.Warn(message); } else { NCacheLog.LogLoggingError("loggerName != null && loggerName.Length > 0"); } }
public static void SetLevel(LoggerNames loggerEnum, Level level) { string loggerName = LoggingInformation.GetLoggerName(LoggingInformation.GetStaticLoggerName(loggerEnum.ToString())); if (loggerName != null && loggerName.Length > 0) { lock (NCacheLog.syncLock) { log4net.Core.Level lvl; switch (level.ToString().ToLower()) { case "all": lvl = log4net.Core.Level.All; break; case "error": lvl = log4net.Core.Level.Error; break; case "fatal": lvl = log4net.Core.Level.Fatal; break; case "info": lvl = log4net.Core.Level.Info; break; case "debug": lvl = log4net.Core.Level.Debug; break; case "warn": lvl = log4net.Core.Level.Warn; break; case "off": lvl = log4net.Core.Level.Off; break; default: lvl = log4net.Core.Level.All; break; } //If the logger doesnot exist it will create one else fetches one log4net.ILog log = log4net.LogManager.GetLogger(loggerName); //adds the logger as a seperate hierchy, not dependant on any other logger log4net.Repository.Hierarchy.Logger l = (log4net.Repository.Hierarchy.Logger)log.Logger; //Applies the logger threshold level l.Level = l.Hierarchy.LevelMap[level.ToString()]; IAppender[] appenderCol = log.Logger.Repository.GetAppenders(); for (int i = 0; i < appenderCol.Length; i++) { IAppender appender = appenderCol[i]; if (appender != null) { if (appender is BufferingForwardingAppender) { ((BufferingForwardingAppender)appender).Threshold = lvl; } if (appender is RollingFileAppender) { ((RollingFileAppender)appender).Threshold = lvl; } } } } } else { NCacheLog.LogLoggingError("loggerName != null && loggerName.Length > 0"); } }