配置文件:zylog.config //這個文件放到主程序的目錄下
<?XML version="1.0" encoding="utf-8" ?>
< configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file type="log4net.Util.PatternString" value="%日志\%date{yyyMMdd}\log.txt" />
<sppendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %message" />
</layout>
</appender>
<root>
<appender-ref ref="LogFileAppender" />
</root>
<logger name="ZYGIS">
<level value="All" />
<appender-ref ref="RollingLogFileAppender"/>
</logger>
</log4net>
< /configuration>
在主程序中調用:
Log.LogOut.Info("關閉軟件,結束運行");