I have implemented RollingFileAppender to log my ASP errors and it works fine.
Now i need to change the file names based on the date value. Currently my log file name is MyLog.log ,its max size is 1 MB and maxBackup is 10. Now i want my log files with date like MyLog_2011-12-29 for each day. I tried the below settings,but its not appending
the date value to the file nameand it just creates the file as MyLog. Any suggestions ?
Nilla2010
Member
48 Points
59 Posts
File Name issue with RollingFileAppender in Log4net
Dec 29, 2011 03:50 PM|LINK
I have implemented RollingFileAppender to log my ASP errors and it works fine.
Now i need to change the file names based on the date value. Currently my log file name is MyLog.log ,its max size is 1 MB and maxBackup is 10. Now i want my log files with date like MyLog_2011-12-29 for each day. I tried the below settings,but its not appending the date value to the file nameand it just creates the file as MyLog. Any suggestions ?
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\TestProj\\MyLog"/>
<staticLogFileName value="false"/>
<appendToFile value="true"/>
<rollingStyle value="Composite"/>
<eventId value="5" />
<eventCategory value="ErrorLogging" />
<datePattern value="yyyy-MM-dd'.log'" />
<maxSizeRollBackups value="10"/>
<maximumFileSize value="1MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n"/>
</layout>
</appender>
mbanavige
All-Star
134964 Points
15421 Posts
ASPInsiders
Moderator
MVP
Re: File Name issue with RollingFileAppender in Log4net
Dec 29, 2011 04:12 PM|LINK
you have two settings for staticLogFileName with the second one still specifying a value of true
what happens if you remove the 2nd redundant staticLogFileName setting?
Nilla2010
Member
48 Points
59 Posts
Re: File Name issue with RollingFileAppender in Log4net
Dec 29, 2011 06:35 PM|LINK
Thanks for the suggestion and it worked.