Esempio n. 1
0
 /// <summary>
 /// 组件logfactory
 /// </summary>
 /// <returns></returns>
 private static INDLoggerFactory BuildNDLoggerFactory(LogConfigProvider logProvider)
 {
     try
     {
         if (logProvider == null || string.IsNullOrEmpty(logProvider.Type) || logProvider.IsEnabled == false)
         {
             if (NDComponentConfig.Instance.IsThrowConfigException)
             {
                 throw new ArgumentNullException("Invalid_Config_LogProvider");
             }
             return(new NullNDLoggerFactory());
         }
         string assemblyName = logProvider.Type.Split(',')[0];
         string typeName     = logProvider.Type.Split(',')[1];
         Type   type         = Type.GetType(typeName + "," + assemblyName);
         return((INDLoggerFactory)Activator.CreateInstance(type));
     }
     catch (Exception ex)
     {
         if (NDComponentConfig.Instance.IsThrowConfigException)
         {
             throw new ArgumentNullException("Invalid_Config_LogProvider");
         }
         return(new NullNDLoggerFactory());
     }
 }
Esempio n. 2
0
        //组建日志
        #region BuildLogConfigProvider
        public LogConfigProvider BuildLogConfigProvider(XElement root)
        {
            LogConfigProvider logProvider = null;
            XElement          rootLog     = root.Element("logprovider");

            if (rootLog != null)
            {
                logProvider            = new LogConfigProvider();
                logProvider.Type       = rootLog.Attribute("type").Value;
                logProvider.IsEnabled  = Convert.ToBoolean(rootLog.Attribute("isenabled").Value.NotEmpty("false"));
                logProvider.LogFactory = BuildNDLoggerFactory(logProvider);
            }
            return(logProvider);
        }