It is possible to define all global configuration, defaults, and targets using run time properties. Furthermore, it is possible to load the configuration from an external log.config file or an app.config/web.config and then override the settings at runtime.
Below is an example of setting global configuration, setting default options, and defining two loggers.
//Clear all the configuration
Log.Config.ResetConfiguration();
//Example of setting a couple global configuration options
Log.Config.IgnoreDuplicates = true;
Log.Config.MaxDuplicates = 2;
//Example of setting a couple default options
//Log every day and keep a weeks worth of files
Log.Config.DefaultFileRollingStyle = RollingStyle.ArchiveTimePeriod;
Log.Config.DefaultRollingTimePeriod = RollingTimePeriod.Daily;
Log.Config.DefaultFileRollingMaxArchiveFiles = 7;
//Add a new file target that only logs errors (This will default to rolling daily)
FileTarget errorTarget = new FileTarget("errors.txt");
errorTarget.MinimumLevel = LoggingLevel.ERROR;
Log.Config.Targets.Add(errorTarget);
//Create an XML Target that rolls every hour (Overriding the daily default)
XmlTarget debugTarget = new XmlTarget("debug.xml");
debugTarget.MinimumLevel = LoggingLevel.DEBUG;
debugTarget.FileRollingTimePeriod = RollingTimePeriod.Hourly;
Log.Config.Targets.Add(debugTarget);
//Log
Log.Debug("This will only log to the debug.xml file");
Log.Debug("This will only log to the debug.xml file");
//This message will not be logged because we are ignoring duplicates
Log.Debug("This will only log to the debug.xml file");
Log.Error("This will log to both the debug.xml file and the errors.txt file");