範例是在程式執行的目錄下建立[年月]資料夾(例如201307)在資料夾下在記錄每天的Log,檔名為年月日.log(例:20130724.log)
所以整個Log的結構會是
Log/201307/20130724.log
Log/201307/20130725.log
Log/201307/20130726.log
.
.
Log/201308/20130801.log
以下是設定檔的設定
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log\\"/>
<appendToFile value="true"/>
<datePattern value="yyyyMM\\\\yyyyMMdd'.log'"/>
<rollingStyle value="Date"/>
<param name="StaticLogFileName" value="false" />
<PreserveLogFileNameExtension value="true"></PreserveLogFileNameExtension>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %logger - %message%newline"/>
</layout>
</appender>
沒有留言:
張貼留言