/// <summary>
        /// Opens the log file for the current application.
        /// </summary>
        /// <param name="logFile">Log file for the current application; if null or string.Empty use the default log file.</param>
        /// <returns>Logger instance.</returns>
        public static Logger Open(string logFile = null)
        {
            LogConfig logConfig = new LogConfig();

            if (!string.IsNullOrEmpty(logFile))
            {
                logConfig.LogFile = logFile;
            }

            int key = logConfig.GetHashCode();

            if (LoggerDictionary.ContainsKey(key))
            {
                return(LoggerDictionary[key]);
            }

            lock (SyncRoot)
            {
                if (LoggerDictionary.ContainsKey(key))
                {
                    return(LoggerDictionary[key]);
                }
                else
                {
                    Logger result = new Logger(logConfig);

                    LoggerDictionary.Add(key, result);

                    return(result);
                }
            }
        }
        /// <summary>
        /// Opens the log configuration file for the current application.
        /// </summary>
        /// <param name="logConfig">LogConfig instance; if null, use the default configuration.</param>
        /// <returns>Logger instance.</returns>
        public static Logger OpenConfig(LogConfig logConfig)
        {
            LogConfig logConfigInfo = logConfig ?? new LogConfig();

            int key = logConfigInfo.GetHashCode();

            if (LoggerDictionary.ContainsKey(key))
            {
                return(LoggerDictionary[key]);
            }

            lock (SyncRoot)
            {
                if (LoggerDictionary.ContainsKey(key))
                {
                    return(LoggerDictionary[key]);
                }
                else
                {
                    Logger result = new Logger(logConfigInfo);

                    LoggerDictionary.Add(key, result);

                    return(result);
                }
            }
        }
        /// <summary>
        /// Opens the log configuration file for the current application.
        /// </summary>
        /// <param name="configFile">Configuration file which contains LogConfig info; if null or string.Empty use the default configuration file.</param>
        /// <param name="throwOnError">true to throw any exception that occurs.-or- false to ignore any exception that occurs.</param>
        /// <returns>Logger instance.</returns>
        public static Logger OpenConfig(string configFile = null, bool throwOnError = false)
        {
            LogConfig logConfig = LogConfigManager.GetLogConfig(configFile, throwOnError);

            int key = logConfig.GetHashCode();

            if (LoggerDictionary.ContainsKey(key))
            {
                return(LoggerDictionary[key]);
            }

            lock (SyncRoot)
            {
                if (LoggerDictionary.ContainsKey(key))
                {
                    return(LoggerDictionary[key]);
                }
                else
                {
                    Logger result = new Logger(logConfig);

                    LoggerDictionary.Add(key, result);

                    return(result);
                }
            }
        }
        /// <summary>
        /// Opens the log file for the current application.
        /// </summary>
        /// <param name="logFile">Log file for the current application; if null or string.Empty use the default log file.</param>
        /// <param name="configFile">Configuration file which contains LoggerSetup info; if null or string.Empty use the default configuration file.</param>
        /// <param name="throwOnError">true to throw any exception that occurs.-or- false to ignore any exception that occurs.</param>
        /// <returns>Logger instance.</returns>
        public static Logger Open(string logFile, string configFile, bool throwOnError = false)
        {
            LogConfig logConfig = new LogConfig();

            if (!string.IsNullOrEmpty(logFile))
            {
                logConfig.LogFile = logFile;
            }

            logConfig.LoggerSetup = LogConfigManager.GetLoggerSetup(configFile, throwOnError);

            int key = logConfig.GetHashCode();

            if (LoggerDictionary.ContainsKey(key))
            {
                return(LoggerDictionary[key]);
            }

            lock (SyncRoot)
            {
                if (LoggerDictionary.ContainsKey(key))
                {
                    return(LoggerDictionary[key]);
                }
                else
                {
                    Logger result = new Logger(logConfig);

                    LoggerDictionary.Add(key, result);

                    return(result);
                }
            }
        }
        /// <summary>
        /// Opens the log file for the current application.
        /// </summary>
        /// <param name="logFile">Log file for the current application; if null or string.Empty use the default log file.</param>
        /// <param name="loggerSetup">LoggerSetup info for the logger instance; if null use the default LoggerSetup info.</param>
        /// <returns>Logger instance.</returns>
        public static Logger Open(string logFile, LoggerSetup loggerSetup)
        {
            LogConfig logConfig = new LogConfig();

            if (!string.IsNullOrEmpty(logFile))
            {
                logConfig.LogFile = logFile;
            }

            if (loggerSetup != null)
            {
                logConfig.LoggerSetup = loggerSetup;
            }

            int key = logConfig.GetHashCode();

            Lock.AcquireReaderLock(Timeout.Infinite);

            try
            {
                if (LoggerDictionary.ContainsKey(key))
                {
                    return(LoggerDictionary[key]);
                }
                else
                {
                    LockCookie lockCookie = Lock.UpgradeToWriterLock(Timeout.Infinite);

                    try
                    {
                        if (LoggerDictionary.ContainsKey(key))
                        {
                            return(LoggerDictionary[key]);
                        }
                        else
                        {
                            Logger result = new Logger(logConfig);

                            LoggerDictionary.Add(key, result);

                            return(result);
                        }
                    }
                    finally
                    {
                        Lock.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                Lock.ReleaseReaderLock();
            }
        }
        /// <summary>
        /// Opens the log configuration file for the current application.
        /// </summary>
        /// <param name="logConfig">LogConfig instance; if null, use the default configuration.</param>
        /// <returns>Logger instance.</returns>
        public static Logger OpenConfig(LogConfig logConfig)
        {
            LogConfig logConfigInfo = logConfig ?? new LogConfig();

            int key = logConfigInfo.GetHashCode();

            Lock.AcquireReaderLock(Timeout.Infinite);

            try
            {
                if (LoggerDictionary.ContainsKey(key))
                {
                    return(LoggerDictionary[key]);
                }
                else
                {
                    LockCookie lockCookie = Lock.UpgradeToWriterLock(Timeout.Infinite);

                    try
                    {
                        if (LoggerDictionary.ContainsKey(key))
                        {
                            return(LoggerDictionary[key]);
                        }
                        else
                        {
                            Logger result = new Logger(logConfigInfo);

                            LoggerDictionary.Add(key, result);

                            return(result);
                        }
                    }
                    finally
                    {
                        Lock.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                Lock.ReleaseReaderLock();
            }
        }