问题
I have an Umbraco instance in the Azure cloud, v4.7 if memory serves correctly. I need to utilise IIS logging to obtain website usage statistics, but there appears to be a limitation.
I have multiple different websites, all using various website templates but the IIS logs don't appear to output the domain name. How can I get IIS to output the domain name?
Below is an example of what the current IIS logs capture (I know this is a BOT crawling the webpages, but I have genuine traffic but can't identify which website is visited):
2012-08-06 00:11:54 10.61.52.73 GET /insurance/insurance/ - 80 - 46.4.38.67 InnovantageBot/1.0+(http://www.innovantage.co.uk/technology/webmaster_information.htm) 200 0 0 390 2012-08-06 00:11:55 10.61.52.73 GET /insurance/reason/ - 80 - 46.4.38.67 InnovantageBot/1.0+(http://www.innovantage.co.uk/technology/webmaster_information.htm) 200 0 0 578 2012-08-06 00:11:55 10.61.52.73 GET /insurance/type/ - 80 00:11:55 10.61.52.73 GET /life/qa/ - 80 - 46.4.38.67 InnovantageBot/1.0+(http://www.innovantage.co.uk/technology/webmaster_information.htm) 200 0 0 359 2012-08-06 00:11:55 10.61.52.73 GET /life/reasons/ - 80 - 46.4.38.67 InnovantageBot/1.0+(http://www.innovantage.co.uk/technology/webmaster_information.htm) 200 0 0 328 2012-08-06 00:11:57 10.61.52.73 GET /insurance/glossary/ - 80 - 46.4.38.67 InnovantageBot/1.0+(http://www.innovantage.co.uk/technology/webmaster_information.htm) 200 0 0 374
回答1:
In your WebRole.cs you can tweak IIS and each site running in IIS. You can choose which fields should be logged and I think you're looking for the LogExtFileFlags.Host
field:
using (var manager = new ServerManager())
{
var siteName = RoleEnvironment.CurrentRoleInstance.Id + "_Web";
var site = manager.Sites[siteName];
site.LogFile.LogExtFileFlags |= LogExtFileFlags.Host;
manager.CommitChanges();
}
Make sure your role is running in elevated mode, change this in your ServiceDefinition.csdef file:
<Runtime executionContext="elevated" />
And you should also be able to change this setting using appcmd.exe:
http://www.iis.net/ConfigReference/system.applicationHost/sites/siteDefaults/logFile#005
来源:https://stackoverflow.com/questions/11847282/umbraco-websites-and-iis-logging