<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
	</configSections>
	<log4net>
		<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
			<!-- 使用正斜杠或双反斜杠作为路径分隔符 -->
			<file value="Log/" />
			<!-- 添加基础文件名 -->
			<param name="PreserveLogFileNameExtension" value="true" />
			<param name="Encoding" value="utf-8"/>
			<param name="AppendToFile" value="true"/>
			<param name="MaxSizeRollBackups" value="10"/>
			<param name="StaticLogFileName" value="false"/>
			<!-- 修改为正确的日期模式 -->
			<param name="DatePattern" value="''yyyy-MM-dd'.log'"/>
			<param name="RollingStyle" value="Date"/>
			<!-- 添加文件锁定机制 -->
			<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
			<layout type="log4net.Layout.PatternLayout">
				<param name="ConversionPattern" value="%date{HH:mm:ss,fff} %-5p-%m%n" />
			</layout>
		</appender>
		<!-- 控制台前台显示日志 -->
		<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
			<mapping>
				<level value="ERROR" />
				<foreColor value="Red, HighIntensity" />
			</mapping>
			<mapping>
				<level value="Info" />
				<foreColor value="Green" />
			</mapping>
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%n%date{HH:mm:ss,fff} [%-5level] %m" />
			</layout>
			<filter type="log4net.Filter.LevelRangeFilter">
				<param name="LevelMin" value="Info" />
				<param name="LevelMax" value="Fatal" />
			</filter>
		</appender>
		<root>
			<!--(高) OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL (低) -->
			<level value="all" />
			<appender-ref ref="ColoredConsoleAppender"/>
			<appender-ref ref="RollingLogFileAppender"/>
		</root>
	</log4net>
</configuration>