Reputation: 152
I want to use log4net for my logging process. But i can't find a config file that makes it writes logs depending of the day of the week. For exemple, this is friday, i want it to write logs on the "friday.log" file. Once it created logs for 1 entire week, it has to come back to "monday.log" and overwrites it from 0.
Thanks.
EDIT: I want to be more accurate to avoid wrongs responses. My question was bad, and not very accurate. I want 7 log files: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. log4net has to found the good day of the week and make his logs into it. After one week, when it's monday again, log4net has to delete all current logs and start logging again in monday's file.
I hope it's more accurate now.
Thanks
Upvotes: 1
Views: 802
Reputation: 2479
Sledge-hammer approach...
Derive a class from RollingFileAppender and override the AdjustFileBeforeAppend method. In your override, you can accomplish the nasty task of deleting last Monday's log file when this Monday's log file is about to be created.
You should be able to generate the file names you want via configuration. (See rbm's answer.)
Upvotes: 1
Reputation: 3253
This will create a file Friday.log
(for today, 18th Sept)
<file type="log4net.Util.PatternString">
<conversionPattern value="%date{dddd}.log" />
</file>
Upvotes: 1