Files
lserp_cs_5.0/插件库/Zhaizj.Framework/Log/Config/SectionLogHandler.cs
T
2026-07-10 15:25:05 +08:00

70 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Zhaizj.Framework.Config.DotNetConfig;
using System.Configuration;
namespace Zhaizj.Framework.Data.Config
{
/// <summary>
/// 数据库配置方式
/// </summary>
/// <remarks>
/// 配置文件格式和说明:
/// <code>
/// <configSections>
/// <sectionGroup name="Zhaizj.Config" type="Zhaizj.Framework.Config.GroupHandler,Zhaizj.Framework">;
/// <section name="DataBase" type="Zhaizj.Framework.Data.Config.SectionHandler, Zhaizj.Framework"/>;
/// </sectionGroup>
/// </configSections>
/// <Zhaizj.Config>
/// <log>
/// <log/>
/// <Zhaizj.Config/>
/// ......
/// </code>
/// </remarks>
public class SectionLogHandler : SectionBaseHandler<SectionLogHandler>
{
/// <summary>
/// 配置日志级别
/// </summary>
[ConfigurationProperty("LogLevel", DefaultValue = "info")]
public string LogLevel
{
get { return (string)this["LogLevel"]; }
}
/// <summary>
/// 配置日志路径
/// </summary>
[ConfigurationProperty("LogFile", DefaultValue = "yyyyMMdd")]
public string LogFile
{
get { return (string)this["LogFile"]; }
}
/// <summary>
/// 配置日志路径
/// </summary>
[ConfigurationProperty("LogPath", DefaultValue = "log")]
public string LogPath
{
get { return (string)this["LogPath"]; }
}
/// <summary>
/// 读取配置文件
/// </summary>
/// <returns></returns>
public string GetLogConfig()
{
StringBuilder tagData = new StringBuilder();
tagData.AppendLine("logLevel : " + LogLevel);
tagData.AppendLine("logFile : " + LogFile);
tagData.AppendLine("logPath : " + LogPath);
return tagData.ToString();
}
}
}