/// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="element">配置节对象</param>
        /// <remarks>
        /// 根据配置信息,创建TextLogFormatter对象
        /// <code source="..\Framework\TestProjects\DeluxeWorks.Library.Test\\Logging\FormatterTest.cs"
        /// lang="cs" region="Get Formatter Test" tittle="获取Formatter对象"></code>
        /// </remarks>
        public TextLogFormatter(LogConfigurationElement element)
            : base(element.Name)
        {
            if (element.ExtendedAttributes.TryGetValue("template", out this.template) == false)
            {
                this.template = Resource.DefaultTextFormat;
            }

            RegisterTokenFunctions();
        }
        /// <summary>
        /// 重载的构造函数,从配置文件中读取、构造
        /// </summary>
        /// <param name="element">配置对象</param>
        /// <remarks>
        /// <code source="..\Framework\src\DeluxeWorks.Library\Logging\Filters\LogFilterFactory.cs"
        /// lang="cs" region="Get FilterPipeline" title="获取Filter对象"></code>
        /// </remarks>
        public PriorityLogFilter(LogConfigurationElement element)
            : base(element.Name)
        {
            string strMin;

            if (element.ExtendedAttributes.TryGetValue("minPriority", out strMin) == false)
            {
                strMin = LogPriority.Normal.ToString();
            }

            //ExceptionHelper.TrueThrow<LogException>(string.IsNullOrEmpty(strminpriority), "没有在配置文件中找到minPriority属性");

            this.minPriority = (LogPriority)Enum.Parse(typeof(LogPriority), strMin);
        }
Beispiel #3
0
 public static ILogFormatter GetFormatter(LogConfigurationElement formatterElement)
 {
     if (formatterElement != null)
     {
         try
         {
             return((ILogFormatter)TypeCreator.CreateInstance(formatterElement.Type, formatterElement));
         }
         catch (Exception ex)
         {
             throw new LogException("创建Formatter对象时出错:" + ex.Message, ex);
         }
     }
     else
     {
         return(null);
     }
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="element">配置节对象</param>
 /// <remarks>
 /// 根据配置信息,创建TextLogFormatter对象
 /// <code source="..\Framework\TestProjects\DeluxeWorks.Library.Test\\Logging\FormatterTest.cs"
 /// lang="cs" region="Get Formatter Test" tittle="获取Formatter对象"></code>
 /// </remarks>
 public XmlLogFormatter(LogConfigurationElement element)
     : base(element.Name)
 {
 }
 private static ILogFilter GetFilterFromConfig(LogConfigurationElement element)
 {
     return((ILogFilter)TypeCreator.CreateInstance(element.Type, element));
     //return ObjectBuilder.GetInstance<LogFilter>(element.TypeName);
 }