. I think the RollingAppender must (logically) ignore that setting since by definition the file gets rebuilt each day when the application restarts/reused. Perhaps it does matter for immediate rollover EVERY time the application starts.
The issue with other combinations of parameters was that the latest file didn't have the time pattern, or that the time pattern was appended as .log20171215 which created a new file time (and file extension = new file type!) each day - or both issues appeared.
Now with this setting you are getting files like this one:
LOG4NET_Sample_Activity-20171215.log
which is what I wanted. To summarize:
Don't put the date pattern in the <file value=... attribute, just define it in the datePattern.
Make sure you have preserveLogFileNameExtension's value attribute set to true.
The extended configuration section in a previous response with
listed works but I did not have to use
. I think the RollingAppender must (logically) ignore that setting since by definition the file gets rebuilt each day when the application restarts/reused. Perhaps it does matter for immediate rollover EVERY time the application starts.
I've tried all the answers, but there was always something missing and not functioning as expected for me.
Then I experimented a bit with the hints given in each answer and was successful with the following setting:
The issue with other combinations of parameters was that the latest file didn't have the time pattern, or that the time pattern was appended as
.log20171215
which created a new file time (and file extension = new file type!) each day - or both issues appeared.Now with this setting you are getting files like this one:
LOG4NET_Sample_Activity-20171215.log
which is what I wanted. To summarize:
Don't put the date pattern in the
<file value=...
attribute, just define it in thedatePattern
.Make sure you have
preserveLogFileNameExtension
's value attribute set to true.Set the
rollingStyle
's attribute value toDate
.In your Log4net config file, use the following parameter with the RollingFileAppender:
For a RollingLogFileAppender you also need these elements and values:
I ended up using (note the '.log' filename and the single quotes around 'myfilename_'):
This gives me: