NET Logging Library
Rolling a File
Basic Tasks > Rolling a File

By default; File Target, CSV Target, XML File Target, and the HTML File Target all roll by discarding MaxEntries.  After it reaches a default of 10,000 log messages, older messages will be discarded.  Other options are available.

 

When archiving by the time period, these are the options:

 

//Example ArchiveMaxLogEntries
//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();  
FileTarget target = new FileTarget("log.txt");   
target.FileRollingStyle = RollingStyle.ArchiveMaxLogEntries;
target.MaxLogEntries = 10000;
Log.Config.Targets.Add(target);
Log.Debug("This is a test");

 

//Example ArchiveSize
//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();  
FileTarget target = new FileTarget("log.txt");   
target.FileRollingStyle = RollingStyle.ArchiveSize;
target.FileRollingMaxSize = 1000000;
Log.Config.Targets.Add(target);
Log.Debug("This is a test");

 

//Example ArchiveTimePeriod Daily
//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();  
FileTarget target = new FileTarget("log.txt");   
target.FileRollingStyle = RollingStyle.ArchiveTimePeriod;
target.FileRollingTimePeriod = RollingTimePeriod.Daily;
Log.Config.Targets.Add(target);
Log.Debug("This is a test");