Does IIS7 log request query string by default?

一世执手 提交于 2020-01-04 01:59:04

问题


Our analytics engine reads IIS logs and I want to know if the query string is included in these, in a default IIS7 setup.

For example, if a user requests http://mysite.com/page?to=otherpage will the logs contain http://mysite.com/page?to=otherpage or http://mysite.com/page?


回答1:


In the Logging settings for the Server or a specific site (I usually configure logging globally), provided you've selected the URI Query (cs-uri-query) logging field then IIS will log the query string:

You can enable all of the fields at one using:

appcmd set config -section:sites -siteDefaults.logFile.logExtFileFlags:Date,Time,ClientIP,UserName,SiteName,ComputerName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,BytesSent,BytesRecv,TimeTaken,ServerPort,UserAgent,Cookie,Referer,ProtocolVersion,Host,HttpSubStatus

In your log file you'll see two fields:

  • cs-uri-stem - which will be the /page part of your url
  • cs-uri-query - which represents the query string e.g. to=otherpage&life=42. You won't see the question mark as this is stripped off.

If there isn't a query string value present in the url then you'll see a hyphen (-) in the cs-uri-query field.

As to what the defaults are...I can't remember off the top of my head. This is because we build our servers off of a set of templates and gold images which aren't really plain vanilla IIS7 boxes, and have all the logging fields already enabled.

However have a poke around the global logging settings and you'll soon find out (assuming someone hasn't touched these since the server was built).

Finally, the global logging settings will be inherited by all the sites on your server unless you override locally at the site level.

You might also find this answer I gave a while back useful which has some other nuggets of information regarding IIS log files:

https://stackoverflow.com/a/11298241/419



来源:https://stackoverflow.com/questions/19918561/does-iis7-log-request-query-string-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!