Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom field(s) logging #267

Closed
olljanat opened this issue Dec 13, 2016 · 6 comments
Closed

Support for custom field(s) logging #267

olljanat opened this issue Dec 13, 2016 · 6 comments
Labels
enhancement The issue is an enhancement request.

Comments

@olljanat
Copy link

We should have support to enable custom field(s) to IIS logging.

I can probably create that feature but how you think that it should be implemented?

Example "X-Forwarded-For" header can be included to logging using this PowerShell command:
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/siteDefaults/logFile/customFields" -name "." -value @{logFieldName='Original-IP';sourceName='X-Forwarded-For';sourceType='RequestHeader'}

It needs these four parameters:

  • Site name/Site defaults selection
  • Field name where value will be stored on log
  • Source parameter name where value will be read
  • Source type, valid inputs are "RequestHeader","ResponseHeader" and "ServerVariable"

Do you prefer that this should be included to existing "xIISLogging" and "xWebsite" modules (and if so how to do input validation correct way?) or would it be better idea create new "xIISCustomLogging", etc module?

@kittholland
Copy link

Thinking about how this would be implemented in this module, for consistency I feel like it would be another CIM class array under xWebsite (like bindings are today) for per-site logging rules, and a modification to xIisLogging for server-wide config.

@nzspambot
Copy link

@kittholland that would be the prefered method; add a new param say LogCustomFlags and at a glance your example looks good, only thing I can think off blindly is add vs set

@olljanat
Copy link
Author

olljanat commented Jan 5, 2017

Let's agree first how configuration should looks like.

First example for xIisLogging:

xIisLogging Logging
{
    LogPath = 'C:\IISLogFiles'
    LogCustomFields = @(
        MSFT_xLogCustomFieldInformation
        {
            LogFieldName   = 'Original-IP'
            SourceName     = 'X-Forwarded-For'
            SourceType     = 'RequestHeader'
        };
        MSFT_xLogCustomFieldInformation
        {
            LogFieldName   = 'ClientEncoding'
            SourceName     = 'Accept-Encoding'
            SourceType     = 'RequestHeader'
        }
    )
}

and first example for xWebsite:

xWebsite NewWebsite
{
    Ensure             = 'Present'
    Name               = 'Default Web Site'
    LogCustomFields    = MSFT_xLogCustomFieldInformation
    {
        LogFieldName   = 'Original-IP'
        SourceName     = 'X-Forwarded-For'
        SourceType     = 'RequestHeader'
    }
}

Did I understand syntax correctly?
Are you happy with naming these settings, etc?

@nzspambot
Copy link

@kittholland 👍 looks like a great start

@kittholland
Copy link

kittholland commented Jan 5, 2017

@olljanat That makes sense to me.

I implemented this internally as a class based resource, doesn't translate straight over but might be helpful if someone else wants to try to implement. The logic is almost identical for website based vs. server level, just change the xpath filterstring. I could try to make some time for it in the future but won't be able to for awhile, I also havent worked with script based resources or implementing CIM classes before.

https://gist.github.com/kittholland/730666229ec9cb7be915768e7d5c9be8

@johlju johlju added enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone. labels Apr 25, 2018
johlju pushed a commit that referenced this issue May 4, 2018
- Updated xWebSite to include ability to manage custom logging fields (issue #267).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label May 4, 2018
@johlju johlju added the in progress The issue is being actively worked on by someone. label May 25, 2018
johlju pushed a commit that referenced this issue Jun 4, 2018
- Updated xIISLogging to include ability to manage custom logging fields (issue #267)
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Jun 4, 2018
chasewilson pushed a commit to chasewilson/xWebAdministration that referenced this issue Jul 30, 2018
- Updated xWebSite to include ability to manage custom logging fields (issue dsccommunity#267).
chasewilson pushed a commit to chasewilson/xWebAdministration that referenced this issue Jul 30, 2018
- Updated xIISLogging to include ability to manage custom logging fields (issue dsccommunity#267)
gstorme pushed a commit to gstorme/xWebAdministration that referenced this issue Feb 14, 2020
- Updated xWebSite to include ability to manage custom logging fields (issue dsccommunity#267).
gstorme pushed a commit to gstorme/xWebAdministration that referenced this issue Feb 14, 2020
- Updated xIISLogging to include ability to manage custom logging fields (issue dsccommunity#267)
@emrgcl
Copy link

emrgcl commented May 12, 2022

Hoping to recycle this issue for Invoke-DscResource since the Invoke-dscresource accepts hashtable and the cim object format causes syntax issue in hashtable. Any workaround is also more than welcome!

Function Test-IISLogCustomfield {

[Cmdletbinding()]
Param(
$LogPath = '%SystemDrive%\inetpub\logs\LogFiles'
)
$Logging =        @{
            LogPath              = $LogPath
            LogCustomFields = MSFT_xLogCustomFieldInformation {
                LogFieldName   = 'Original-IP'
                SourceName     = 'X-Forwarded-For'
                SourceType     = 'RequestHeader'
            };
        }

(Invoke-DscResource -Name xIisLogging -Method Test -ModuleName @{ModuleName='xWebAdministration';RequiredVersion='3.2.0'} -Property $Logging).IndesiredState.ToBoolean($_)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

No branches or pull requests

5 participants