Help and Support
 

powered byLive Search

How to use the Appcmd.exe command-line tool to enable and configure HTTP logging and other features in Internet Information Services 7.0

Article ID:930909
Last Review:January 23, 2007
Revision:1.3
On This Page

INTRODUCTION

The following features cannot be configured by using the Microsoft Internet Information Services (IIS) 7.0 Manager:
HTTP logging
HTTP redirection
HTTP response headers
HTTP compression
To enable and configure these features, you must use the Appcmd.exe command-line tool instead.

Back to the top

MORE INFORMATION

To enable these features in IIS 7.0, use the Appcmd.exe command-line tool. When you use this tool, you must first enable the feature. Then, you must configure the settings for the feature. When you run the Appcmd.exe tool, settings are updated in the %windir%\System32\Inetsrv\Config\ApplicationHost.config file.

The following sections describe how to use the Appcmd.exe tool to enable various HTTP features in IIS 7.0. To determine other IIS attributes and settings that you can change by using the Appcmd.exe tool, view the full schema in the %windir%\System32\Inetsrv\Config\Schema\IIS_schema.xml file.

Back to the top

HTTP logging

To enable logging for HTTP requests, follow these steps:
1.Click StartStart button, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

User Account Control permission If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
2.Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
3.Type the following command, and then press ENTER:
appcmd set config /section:httpLogging /dontLog:False /selectiveLogging:LogAll
Note This command configures HTTP logging to use the default logging settings from the schema file for all Web sites that are configured on the Web server. The selectiveLogging attribute can equal one of the following values:
LogError
This value specifies that all errors are logged.
LogSuccessful
This value specifies that all successful requests are logged.
LogAll
This value specifies that all requests are logged.
To disable logging for HTTP requests, type the following command, and then press ENTER:
appcmd set config /section:httpLogging /dontLog:True

Additional logging options

After you have enabled logging for HTTP requests, you can set additional logging options. For example, you can set specific information to log. The following command demonstrates how to log only HTTP substatus information for all Web sites:
appcmd set config /section:sites -siteDefaults.logFile.logExtFileFlags:HttpSubStatus
You can log the following information for the Web site that has an ID value of 1:
HTTP substatus
Host
Time
Date
To do this, use a command that resembles the following:
appcmd set config /section:sites /[id='1'].logFile.logExtFileFlags:HttpSubStatus,Host,Time,Date

Back to the top

HTTP redirection

To enable HTTP redirection, follow these steps:
1.Click StartStart button, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

User Account Control permission If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
2.Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
3.Type the following command, and then press ENTER:
appcmd set config /section:httpRedirect /enabled:true
To add an HTTP redirection rule, type the following command, and then press ENTER:
appcmd set config /section:httpRedirect/+[wildcard='WildcardHeader',destination='Destination']
Note In this command, WildcardHeader represents the Web page or pages that you want to redirect. Destination represents the destination Web page to which the WildcardHeader value redirects.

To disable HTTP redirection, type the following command, and then press ENTER:
appcmd set config /section:httpRedirect /enabled:false

Back to the top

HTTP response headers

To add an HTTP response header, follow these steps:
1.Click StartStart button, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

User Account Control permission If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
2.Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
3.Type the following command, and then press ENTER:
appcmd set config /section:httpProtocol /+customHeaders.[name='HeaderName',value='HeaderValue']
Note In this command, HeaderName represents the name of the HTTP header that you are adding. HeaderValue represents the value of the HTTP header that you are adding.
To edit an HTTP response header, type the following command, and then press ENTER:
appcmd set config /section:httpProtocol /customHeaders.[name='HeaderName']. value:HeaderValue
Note In this command, HeaderName represents the name of the HTTP header that you want to edit. HeaderValue represents the value of the HTTP header that you are editing.

To view a list of HTTP response headers, type the following command, and then press ENTER:
appcmd list config /section:httpProtocol

Back to the top

HTTP compression

To enable HTTP compression, follow these steps:
1.Click StartStart button, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

User Account Control permission If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
2.Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
3.Enable static content compression or dynamic content compression. To do this, use one of the following methods:
To enable static content compression, type the following command, and then press ENTER:
appcmd set config /section:urlCompression /doStaticCompression:True
To enable dynamic content compression, type the following command, and then press ENTER:
appcmd set config /section:urlCompression /doDynamicCompression:True

Back to the top

REFERENCES

For more information about the Appcmd.exe tool, visit the following Microsoft Web site:
http://www.iis.net/default.aspx?tabid=2&subtabid=25&i=954&p=1 (http://www.iis.net/default.aspx?tabid=2&subtabid=25&i=954&p=1)
For more information about how to configure HTTP logging in IIS 7.0, visit the following Microsoft Web site:
http://technet2.microsoft.com/WindowsServer/en/library/bcb7fbfa-8f61-42ca-88ca-59123be5f0011033.mspx (http://technet2.microsoft.com/WindowsServer/en/library/bcb7fbfa-8f61-42ca-88ca-59123be5f0011033.mspx)
For more information about how to edit a redirect rule in IIS 7.0, visit the following Microsoft Web site:
http://technet2.microsoft.com/windowsserver2008/en/library/c1d20020-8a63-4f3e-a141-38c01a5286831033.mspx (http://technet2.microsoft.com/windowsserver2008/en/library/c1d20020-8a63-4f3e-a141-38c01a5286831033.mspx)
For more information about how to configure HTTP response headers in IIS 7.0, visit the following Microsoft Web site:
http://technet2.microsoft.com/WindowsServer/en/library/37283911-0b7f-40ef-9cad-7ba05425e7e71033.mspx (http://technet2.microsoft.com/WindowsServer/en/library/37283911-0b7f-40ef-9cad-7ba05425e7e71033.mspx)
For more information about how to configure HTTP compression in IIS 7.0, visit the following Microsoft Web site:
http://technet2.microsoft.com/WindowsServer/en/library/30e64245-ec6b-4c4e-891b-b7249e36c0a01033.mspx (http://technet2.microsoft.com/WindowsServer/en/library/30e64245-ec6b-4c4e-891b-b7249e36c0a01033.mspx)

Back to the top


APPLIES TO
Microsoft Internet Information Services 7.0

Back to the top

Keywords: 
kbhowto kbinfo KB930909

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.