/// <summary> /// Instances this instance. /// </summary> /// <returns></returns> public static LogProvider Instance() { // Use the cache because the reflection used later is expensive Cache cache = HttpRuntime.Cache; string cacheKey; // Get the names of providers ProviderConfiguration config; config = ProviderConfiguration.GetProviderConfiguration(providerType); //If config not found (missing web.config) if (config == null) { //Try to provide a default anyway XmlDocument defaultNode = new XmlDocument(); defaultNode.LoadXml( "<log defaultProvider=\"Log4NetLog\"><providers><clear /><add name=\"Log4NetLog\" type=\"Rainbow.Framework.Logging.Log4NetLogProvider, Rainbow.Provider.Implementation\" /></providers></log>"); // Get the names of providers config = new ProviderConfiguration(); config.LoadValuesFromConfigurationXml(defaultNode.DocumentElement); } // Read specific configuration information for this provider ProviderSettings providerSettings = (ProviderSettings)config.Providers[config.DefaultProvider]; // In the cache? cacheKey = "Rainbow::Configuration::Log::" + config.DefaultProvider; if (cache[cacheKey] == null) { // The assembly should be in \bin or GAC, so we simply need // to get an instance of the type try { cache.Insert(cacheKey, ProviderHelper.InstantiateProvider(providerSettings, typeof(LogProvider))); } catch (Exception e) { throw new Exception("Unable to load provider", e); } } return((LogProvider)cache[cacheKey]); }