Search code examples
iisloggingwebserveriis-8

Can't enable IIS logging without using the GUI


IIS logging has been disable via the GUI: enter image description here

I just want to enable it, but apparently this is impossible without using the GUI.

Commands I have tried:

appcmd set config /section:httpLogging /dontLog:False /selectiveLogging:LogAll

Set-ItemProperty "IIS:\Sites\MySite" -name logFile -value @{enabled=$true}

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='MySite']/logFile" -name "LogExtFileFlags" -value @{enabled=$true}

When I do a Get-Windowsfeature I can see IIS-HttpLogging is marked as enabled.

Nothing I have tried has enabled IIS logging, I have to use the GUI and click enable.

When I run this it returns true:

PS C:\Windows\System32\inetsrv> (Get-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' -filter "/system.applicationHost/sites/MYSite" ).logfile.enabled

Edit: So logging seems to work even though the GUI displays it as "disabled". Perhaps this is a bug in the GUI?

Edit2: OK so if I try the appcmd command and target my specific site I get this error:

.\appcmd set config "MySite" /section:httpLogging /dontLog:False

PS C:\Windows\System32\inetsrv> .\appcmd set config "MySite" /section:httpLogging /dontLog:False
ERROR ( message:Can not set attribute "dontLog" to value "False".. Reason: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false

Is says the section is locked at the parent level, but I was able to click enable for the site's logging in the GUI and did not get any errors.


Solution

  • As I wrote the clone of IIS Manager, I can tell you the "Enable/Disable" button links to an attribute called "dontLog", https://github.com/jexuswebserver/JexusManager/blob/master/JexusManager.Features.Logging/LoggingFeature.cs

    Its reference can be found at

    https://www.iis.net/configreference/system.webserver/httplogging