Example #1
0
        /// <summary>
        /// LogConfig
        /// </summary>
        /// <param name="sectionName"></param>
        public LogConfig(string sectionName)
        {
            Filter = new LogFilter();

            object section = ConfigurationManager.GetSection(sectionName);
            NameValueCollection nameValue = section as NameValueCollection;

            if (nameValue != null)
            {
                foreach (string key in nameValue)
                {
                    string value = nameValue[key];
                    switch (key)
                    {
                    case "Path":
                        Path = value;
                        break;

                    case "File":
                        File = value;
                        break;

                    case "Format":
                        Format = value;
                        break;

                    case "MaxSize":
                        MaxSize = Convert.ToInt32(value);
                        break;

                    case "Mode":
                        string[] modes = value.Split('|');
                        foreach (string mode in modes)
                        {
                            Mode |= (LogMode)Enum.Parse(typeof(LogMode), mode);
                        }
                        break;

                    case "Level":
                        Filter.Level = (LogLevel)Enum.Parse(typeof(LogLevel), value);
                        break;

                    case "Append":
                        Append = Convert.ToBoolean(value);
                        break;

                    case "Tag":
                        Filter.Tag = value.Split('|');
                        break;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// LogConfig
        /// </summary>
        /// <param name="sectionName"></param>
        public LogConfig(string sectionName)
        {
            Filter = new LogFilter();

            object section = ConfigurationManager.GetSection(sectionName);
            NameValueCollection nameValue = section as NameValueCollection;
            if (nameValue != null)
            {
                foreach (string key in nameValue)
                {
                    string value = nameValue[key];
                    switch (key)
                    {
                        case "Path":
                            Path = value;
                            break;
                        case "File":
                            File = value;
                            break;
                        case "Format":
                            Format = value;
                            break;
                        case "MaxSize":
                            MaxSize = Convert.ToInt32(value);
                            break;
                        case "Mode":
                            string[] modes = value.Split('|');
                            foreach (string mode in modes)
                            {
                                Mode |= (LogMode)Enum.Parse(typeof(LogMode), mode); 
                            }
                            break;
                        case "Level":
                            Filter.Level = (LogLevel)Enum.Parse(typeof(LogLevel), value);
                            break;
                        case "Append":
                            Append = Convert.ToBoolean(value);
                            break;
                        case "Tag":
                            Filter.Tag = value.Split('|');
                            break;
                        
                    }
                }
            }
                
        }
Example #3
0
 /// <summary>
 /// 
 /// </summary>
 public LogConfig()
 {
     Filter = new LogFilter();
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 public LogConfig()
 {
     Filter = new LogFilter();
 }