Hello Everyone,
I want to use URL Rewrite in order to add a server variable and then customize IIS log in order to capture the variable.
I successfully add the variable:
in applicationHost.config:
<location path="test"><system.webServer><security><authentication><anonymousAuthentication userName="" /></authentication></security><rewrite><allowedServerVariables><add name="MyVar" /></allowedServerVariables></rewrite></system.webServer></location>
And in site's Web.Config:
<rewrite><rules><rule name="pippo"><match url=".*" /><serverVariables><set name="MyVar" value="myvalue" /></serverVariables><action type="None" /><conditions></conditions></rule></rules></rewrite>
Then I try to log the variable in IIS Log
<logFile><customFields><clear /><add logFieldName="MyVar" sourceName="MyVar" sourceType="ServerVariable" /><add logFieldName="server" sourceName="SERVER_SOFTWARE" sourceType="ServerVariable" /></customFields></logFile>
But it doesn't work. I tried writing a simple page:
<% @ Page Language="C#" %><% Response.Write("MyVar: "+Request.ServerVariables["MyVar"]+"<br/>"); %>
and it works: the value is returned.
May you help me to understand why it's not logging?
Best regards,
G.