Skip to content

Possible to set custom logging (x-forwared-for) via xWebAdministration? #382

@mhendric

Description

@mhendric

I wanted to see if it's possible to configure custom logging via xWebAdministration, and if someone could provide an example on how to use it to configure the below XML snippet which adds the x-forwarded-for header to IIS logs? The assumption is that the logFile block, and everything underneath it, does not exist, and would need to be created and configured. I'm having trouble figuring out how to get xWebConfigPropertyCollection to create new elements, and also to configure something that has more than 2 properties, like the add block below. I also don't know how I'd add an empty block, like the clear block.

From: https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/logfile/customfields/add

<sites>
    <site name="Default Web Site" id="1">
        <logFile logFormat="W3C" logTargetW3C="File, ETW">
            <customFields maxCustomFieldLength="4095">
                <clear />
                <add logFieldName="X-Forwarded-For" sourceName="X_FORWARDED_FOR" 
                    sourceType="RequestHeader" />
            </customFields>
        </logFile>
    </site>   
</sites>

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationThe issue is related to documentation only.help wantedThe issue is up for grabs for anyone in the community.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions