While the question is tagged with iis-7, this is the top hit when searching on X-Forwarded-For so I thought I would go ahead and provide this information for IIS 8.5.
IIS 8.5 and later
IIS 8.5 introduced the Enhanced Logging feature that easily allows the administrator to log HTTP request headers such as X-Forwarded-For. This answer is adapted from the linked page.
Open IIS Manager.
Select the site or server in the Connections pane, and then double-click Logging. Note that enhanced logging is available only for site-level logging - if you select the server in the Connections pane, then the Custom Fields section of the W3C Logging Fields dialog is disabled.
In the Format field under Log File, select W3C and then click Select Fields....
In the W3C Logging Fields dialog, click Add Field.... Note that enhanced logging is available only for site-level logging - if you selected the server in the Connections pane, then Add Field... is disabled.
In the Add Custom Field dialog, enter a Field Name such as c-ip-original
to identify the custom field within the log file. Please note that the field name cannot contain spaces.
Select Request Header in the Source Type list.
Enter X-FORWARDED-FOR
in Source.
Click OK.
Click OK.
Click Apply in the Actions pane to apply the new configuration.
Once the custom fields have been configured, IIS will create new text log files with "_x" appended to the file name to indicate that the file contains custom fields.
Note that the total size of data collected from all custom fields cannot exceed 65,536 bytes. If the total exceeds 65,536 bytes, then IIS will truncate the data.