The XmlLog4jTarget creates an XML file that is compatible with several 3rd party log viewers. See the Log Viewers section of the help file. It 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:
LogFilePath - The path to the log file
//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();
XmlLog4jTarget target = new XmlLog4jTarget("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.xml
%MyDocuments%\mylogfile.xml