NET Logging Library
Logging to an XML File
Basic Tasks > Logging to an XML File

The XML File target automatically defaults to performing in place rolling.  After 10,000 entries are reached, older items will be discarded.  This behavior can be overridden.  The connection to the file will be automatically closed if nothing has been written to the log for one second. 

 

It has these properties that can be configured:

 

//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();   
XmlTarget target = new XmlTarget("log.xml");       
Log.Config.Targets.Add(target);

Log.Debug("This is a test");

 

You can specify dynamic paths using these constructs:
 
Data Directory
http://stackoverflow.com/questions/1409358/ado-net-datadirectory-where-is-this-documented
|DataDirectory|\mylogfile.xml

Server.MapPath for ASP.NET, Web Services, and WCF
http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx
Server.MapPath("~/App_Data")\mylogfile.xml

Special Folders
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
%ApplicationData%\mylogfile.xml
%CommonApplicationData%\mylogfile.xml
%LocalApplicationData%\mylogfile.xm
%MyDocuments%\mylogfile.xml