So, a trip down memory lane is in order.
Starting (for us) with IIS7, we installed the IIS Advanced Logging add-in, which gave us the ability to add new fields and direct that data to a different location versus the default logging location.
This has worked well for us up to and including IIS 8.5.
Introduce IIS 10
Advanced Logging MSI will not install on Windows 2016, you get a pop-up saying that IIS version 7.0 is required to use IIS AL 1.0
I know that custom logging was added to IIS 8.5 but we continued to use the AL 1.0 since our install script was still working and we didn't want to spend the time changing the script to work with the built-in feature.
In my Powershell script to install IIS and IIS AL, I have a function for adding or setting web configurations like below:
###############################################################################################
Function Update-WebConfiguration ($Action, $Filter, $Name, $Value){
Try{
If ($Action -eq "Set"){
$Command = "Set-WebConfigurationProperty -Filter $Filter -Name $Name -Value $Value"
$Result = Invoke-Expression -Command $Command -ErrorAction SilentlyContinue -ErrorVariable errVariable -WarningAction SilentlyContinue -WarningVariable wrnVariable
}
ElseIf ($Action -eq "Add"){
$Command = "Add-WebConfigurationProperty -Filter $Filter -Name $Name -Value $Value"
$Result = Invoke-Expression -Command $Command
}
}
Catch{
Return $false
}
Return $true
}
###############################################################################################
We changed the location of the advanced log files so as to not interrupt any current process that was using the base logging location or files with this code:
###############################################################################################
Write-Host "[$Now] Setting Advanced Logging Default Log Location..." -ForegroundColor Green -NoNewline
If (!(Update-WebConfiguration -Action 'Set' -Filter '/system.applicationHost/advancedLogging/serverLogs' -Name 'directory' -Value "$strIISAdvLogFolder")){
Write-Host "FAILURE" -ForegroundColor Red
}
Else{
Write-Host "SUCCESS" -ForegroundColor Green
}
###############################################################################################
Then we added advanced logging fields using code like this:
###############################################################################################
Write-Host "[$Now] Add Logging For REMOTEADDRESS Property..." -ForegroundColor Green -NoNewline
If (!(Update-WebConfiguration -Action 'Add' -Filter '/system.webServer/advancedLogging/server' -Name 'fields' -Value '@{id="REMOTEADDRESS";sourceName="REMOTEADDRESS";sourceType="RequestHeader";logHeaderName="";category="Default";description="";defaultValue="";loggingDataType="TypeLPCSTR"}')){
Write-Host "FAILURE" -ForegroundColor Red
}
Else{
Write-Host "SUCCESS" -ForegroundColor Green
}
###############################################################################################
This all flies out the window with IIS 10.
Anyone have ideas on how to get this to work with IIS 10?
I need to be able to set advanced logging fields BEFORE any sites are created. If done after, the installer will never know its needed and business partners would just ignore the requirement and then later on when we need the log data, we will discover
they never added the fields after they stood up the site(s) that their application has.