private static ILoggerFactoryAdapter BuildLoggerFactoryAdapter()
        {
            LogSetting section = null;

            try
            {
                section = (LogSetting)ConfigurationManager.GetSection(IBATIS_SECTION_LOGGING);
            }
            catch (Exception exception)
            {
                ILoggerFactoryAdapter adapter = BuildDefaultLoggerFactoryAdapter();
                adapter.GetLogger(typeof(LogManager)).Warn("Unable to read configuration. Using default logger.", exception);
                return(adapter);
            }
            if ((section != null) && !typeof(ILoggerFactoryAdapter).IsAssignableFrom(section.FactoryAdapterType))
            {
                ILoggerFactoryAdapter adapter2 = BuildDefaultLoggerFactoryAdapter();
                adapter2.GetLogger(typeof(LogManager)).Warn("Type " + section.FactoryAdapterType.FullName + " does not implement ILoggerFactoryAdapter. Using default logger");
                return(adapter2);
            }
            if (section != null)
            {
                if (section.Properties.Count > 0)
                {
                    try
                    {
                        object[] args = new object[] { section.Properties };
                        return((ILoggerFactoryAdapter)Activator.CreateInstance(section.FactoryAdapterType, args));
                    }
                    catch (Exception exception2)
                    {
                        ILoggerFactoryAdapter adapter4 = BuildDefaultLoggerFactoryAdapter();
                        adapter4.GetLogger(typeof(LogManager)).Warn("Unable to create instance of type " + section.FactoryAdapterType.FullName + ". Using default logger.", exception2);
                        return(adapter4);
                    }
                }
                try
                {
                    return((ILoggerFactoryAdapter)Activator.CreateInstance(section.FactoryAdapterType));
                }
                catch (Exception exception3)
                {
                    ILoggerFactoryAdapter adapter5 = BuildDefaultLoggerFactoryAdapter();
                    adapter5.GetLogger(typeof(LogManager)).Warn("Unable to create instance of type " + section.FactoryAdapterType.FullName + ". Using default logger.", exception3);
                    return(adapter5);
                }
            }
            ILoggerFactoryAdapter adapter6 = BuildDefaultLoggerFactoryAdapter();

            adapter6.GetLogger(typeof(LogManager)).Warn("Unable to read configuration IBatisNet/logging. Using default logger.");
            return(adapter6);
        }
        /// <summary>
        /// Builds the logger factory adapter.
        /// </summary>
        /// <returns></returns>
        private static ILoggerFactoryAdapter BuildLoggerFactoryAdapter()
        {
            LogSetting setting = null;

            try
            {
#if dotnet2
                setting = (LogSetting)ConfigurationManager.GetSection(IBATIS_SECTION_LOGGING);
#else
                setting = (LogSetting)ConfigurationSettings.GetConfig(IBATIS_SECTION_LOGGING);
#endif
            }
            catch (Exception ex)
            {
                ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
                ILog log = defaultFactory.GetLogger(typeof(LogManager));
                log.Warn("Unable to read configuration. Using default logger.", ex);
                return(defaultFactory);
            }

            if (setting != null && !typeof(ILoggerFactoryAdapter).IsAssignableFrom(setting.FactoryAdapterType))
            {
                ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
                ILog log = defaultFactory.GetLogger(typeof(LogManager));
                log.Warn("Type " + setting.FactoryAdapterType.FullName + " does not implement ILoggerFactoryAdapter. Using default logger");
                return(defaultFactory);
            }

            ILoggerFactoryAdapter instance = null;

            if (setting != null)
            {
                if (setting.Properties.Count > 0)
                {
                    try
                    {
                        object[] args = { setting.Properties };

                        instance = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType, args);
                    }
                    catch (Exception ex)
                    {
                        ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
                        ILog log = defaultFactory.GetLogger(typeof(LogManager));
                        log.Warn("Unable to create instance of type " + setting.FactoryAdapterType.FullName + ". Using default logger.", ex);
                        return(defaultFactory);
                    }
                }
                else
                {
                    try
                    {
                        instance = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType);
                    }
                    catch (Exception ex)
                    {
                        ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
                        ILog log = defaultFactory.GetLogger(typeof(LogManager));
                        log.Warn("Unable to create instance of type " + setting.FactoryAdapterType.FullName + ". Using default logger.", ex);
                        return(defaultFactory);
                    }
                }
            }
            else
            {
                ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
                ILog log = defaultFactory.GetLogger(typeof(LogManager));
                log.Warn("Unable to read configuration IBatisNet/logging. Using default logger.");
                return(defaultFactory);
            }

            return(instance);
        }