I am using log4net in my .NET projects and logs are being created with names like:
C:\\Inetpub\\zz_appLogs\\<hard coded sitename>\\<yyyyMMdd>\\<hard coded file name with txt extension>
Now I want to change the log file name with current site name in IIS. I have tried this in log4net settings but it didnt work:
<file type="log4net.Util.PatternString"
value="C:\Inetpub\zz_appLogs\MYsiteLogs\" />
...
<datePattern
value="yyyyMMdd\\"%property{CURRENTSITENAME}_info.txt"" />
The resultant logs are having filename as follows:
C:\Inetpub\zz_ErrorLogs\MVCdoctoolLogs\20100304\
%property{CURRENTSITENAME}_error.txt`
I am setting the property in app_start in Global.ascx file of project:
log4net.GlobalContext.Properties["CURRENTSITENAME"] =
System.Web.Hosting.HostingEnvironment.SiteName;
Can you tell me how I can set the sitename from IIS in the resultant txt file created by log4net.
thanks in advance :)