コード例 #1
0
ファイル: Logger.cs プロジェクト: shekky/cuttingedge.logging
        static Logger()
        {
            try
            {
                LoggingSection section = GetConfigurationSection();

                LoggingProviderCollection providerCollection = LoadAndInitializeProviderCollection(section);

                LoggingProviderBase defaultProvider = GetDefaultProvider(section, providerCollection);

                InitializeFallbackProviders(providerCollection);

                CompleteInitialization(providerCollection, defaultProvider);

                CircularReferenceFinder.Validate(providerCollection);

                Logger.providers = providerCollection;
                Logger.provider  = defaultProvider;
            }
            catch (ProviderException pex)
            {
                // When a ProviderException or ConfigurationException is thrown, we store those and throw them
                // when one of the public methods of Logger is called. This way the original exceptions are
                // thrown and not a TypeInitializeException that wraps the original.
                InitializationException = pex;
            }
            catch (ConfigurationException ceex)
            {
                InitializationException = ceex;
            }
        }
コード例 #2
0
ファイル: Logger.cs プロジェクト: shekky/cuttingedge.logging
        // Throws a ConfigurationErrorsException (descendant of ConfigurationException) on failure.
        private static LoggingProviderBase GetDefaultProvider(LoggingSection loggingSection,
                                                              LoggingProviderCollection providerCollection)
        {
            LoggingProviderBase defaultProvider = providerCollection[loggingSection.DefaultProvider];

            if (defaultProvider == null)
            {
                PropertyInformation property = loggingSection.ElementInformation.Properties["defaultProvider"];

                throw new ConfigurationErrorsException(
                          SR.NoDefaultLoggingProviderFound(SectionName), property.Source, property.LineNumber);
            }

            return(defaultProvider);
        }
コード例 #3
0
ファイル: Logger.cs プロジェクト: shekky/cuttingedge.logging
        // Throws a ConfigurationException (or a descendant) on failure.
        private static LoggingProviderCollection LoadAndInitializeProviderCollection(LoggingSection section)
        {
            LoggingProviderCollection providerCollection = new LoggingProviderCollection();

            foreach (ProviderSettings settings in section.Providers)
            {
                LoggingProviderBase loggingProvider = InstantiateLoggingProvider(settings);

                providerCollection.Add(loggingProvider);
            }

            providerCollection.SetReadOnly();

            return(providerCollection);
        }