We are using the IIS Advanced Logging module for our IIS site. I was able to figure out how to setup the main settings from Google searching. Main one I referenced is here: https://rafpe.ninja/2015/08/05/iis-advanced-logging-first-approach/
However, I can't find a way to programmatically change the log directory for that specific log definition. When I edit the value through the IIS Mgmt Console UI, it adds an entry in the system.applicationHost/Sit
> section in the applicationHost.config file. See the "advancedLogging" entry at the end of the site's section sampled below.
<site name="MySite" id="2" serverAutoStart="true">
<application path="/" applicationPool="MyAppPool">
<virtualDirectory path="/" physicalPath="Z:\MySite\Application Server" />
<virtualDirectory path="/Serengeti" physicalPath="Z:\AutoRedirect" />
<application path="/WebServices" applicationPool="Tracker">
<virtualDirectory path="/" physicalPath="Z:\MySite\Application Server\WebServices" />
<binding protocol="http" bindingInformation="*:80:" />
<applicationDefaults preloadEnabled="true" />
<advancedLogging directory="Z:\AdvancedLogging" />
I've tried all sorts of versions of Add-WebConfiguration, Set-WebConfiguration, Set-WebConfigurationProper
ty. None work, or I get the config section locked issue. Which I tried using the ServerManager assembly to try and unlock it, no luck.
The interesting thing is, after setting the path in the UI, if I try using the Get-WebConfigurationProper
ty to validate the setting in powershell:
(Get-WebConfiguration -Filter /system.applicationHost/sites/sitedefaults/advancedLogging -Location Tracker).Attributes
It shows as the server default value %SystemDrive%\inetpub\logs
ogs. The only way I've been able to get the accurate value is by using the Get-Website cmdlet and drilling into the properties of the returned site object.
Does anyone know how I can change the log directory for IIS Advanced Logging? I'm trying to work this into server deployment automation.
Server is Windows 2012 R2