log4j 引入
配置文件
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="log.txt" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="100000" />
<param name="RollingStyle" value="Date" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value=".yyyy-MM-dd.'log'" />
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[BEGIN_LOG--------------------------------------]" />
<param name="Footer" value="[END_LOG----------------------------------------]" />
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<root>
<level value="info" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="log.txt" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="100000" />
<param name="RollingStyle" value="Date" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value=".yyyy-MM-dd.'log'" />
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[BEGIN_LOG--------------------------------------]" />
<param name="Footer" value="[END_LOG----------------------------------------]" />
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<root>
<level value="info" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
启动的时候 初始化
log4net.Config.DOMConfigurator.Configure();
以后就可以
using log4net;
log4net.ILog log = log4net.LogManager.GetLogger("Frm_Login");
log.Info("Start Lonin From.");
等等。。
posted on 2006-09-01 22:21 hello csharp 阅读(899) 评论(0) 编辑 收藏 举报