Reputation: 1600
I read the documentation of it but I just don't understand it.It says:
RollingFileAppender can roll log files based on size or date or both depending on the setting of the RollingStyle property. When set to Size the log file will be rolled once its size exceeds the MaximumFileSize. When set to Date the log file will be rolled once the date boundary specified in the DatePattern property is crossed. When set to Composite the log file will be rolled once the date boundary specified in the DatePattern property is crossed, but within a date boundary the file will also be rolled once its size exceeds the MaximumFileSize. When set to Once the log file will be rolled when the appender is configured. This effectively means that the log file can be rolled once per program execution.
I am trying to find a way everytime I use the file appender a new file to be created but not to append to the same one.
Upvotes: 1
Views: 4101
Reputation: 1206
RollingFileAppender means the system creates a log file based on your filters, this way you can have log files based on dates (one file each day), or get the file splitted into small chunks when it hits certain size.
From my point of view, and depending on the loggin you do, the best option in to roll flat each day. This way you have your log in a very handy size and don't have to deal with massive files that would need specific tools to work with them.
Upvotes: 4
Reputation: 9396
Your question itself has the answer:
"When set to Once the log file will be rolled when the appender is configured. This effectively means that the log file can be rolled once per program execution.
So, when you set your RollingFileAppender to "once", then every time you execute your program, a new log file will be created.
Upvotes: 0
Reputation: 13970
Ten use the regular File Appender and set AppendToFile=false
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="log-file.txt" />
<appendToFile value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.AppendToFile.html http://logging.apache.org/log4net/release/config-examples.html
Upvotes: 0