-
Notifications
You must be signed in to change notification settings - Fork 149
IisLogging
dscbot edited this page Dec 7, 2023
·
3 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
LogPath | Key | String | The directory to be used for logfiles | |
LogFlags | Write | StringArray[] | The W3C logging fields |
Date , Time , ClientIP , UserName , SiteName , ComputerName , ServerIP , Method , UriStem , UriQuery , HttpStatus , Win32Status , BytesSent , BytesRecv , TimeTaken , ServerPort , UserAgent , Cookie , Referer , ProtocolVersion , Host , HttpSubStatus
|
LogPeriod | Write | String | How often the log file should rollover |
Hourly , Daily , Weekly , Monthly , MaxSize
|
LogTruncateSize | Write | String | How large the file should be before it is truncated | |
LoglocalTimeRollover | Write | Boolean | Use the localtime for file naming and rollover | |
LogFormat | Write | String | Format of the Logfiles. Only W3C supports LogFlags |
IIS , W3C , NCSA
|
LogTargetW3C | Write | String | Specifies whether IIS will use Event Tracing or file logging |
File , ETW , File,ETW
|
LogCustomFields | Write | DSC_LogCustomField[] | Custom logging field information in the form of an array of embedded instances of DSC_LogCustomField CIM class |
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
LogFieldName | Required | String | Name for the custom field | |
SourceName | Required | String | Name for the source type | |
SourceType | Required | String | Specify the source type |
RequestHeader , ResponseHeader , ServerVariable
|
Ensure | Write | String | Indicates if the custom log field should be present or absent. Defaults to Present. |
Present , Absent
|
The IisLogging
DSC resource is used to set the logfile settings for all
websites; for individual websites use the Log options under xWebSite.
- Target machine must be running Windows Server 2012 R2 or later.
All issues are not listed here, see here for all open issues.
configuration Sample_IisLogging_LogCustomFields_EnsureAbsent
{
param
(
# Target nodes to apply the configuration
[String[]] $NodeName = 'localhost'
)
# Import the module that defines custom resources
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
IisLogging Logging
{
LogPath = 'C:\IISLogFiles'
Logflags = @('Date','Time','ClientIP','ServerIP','UserAgent')
LogFormat = 'W3C'
LogTargetW3C = 'File,ETW'
LogCustomFields = @(
DSC_LogCustomField
{
LogFieldName = 'ClientEncoding'
SourceName = 'Accept-Encoding'
SourceType = 'RequestHeader'
Ensure = 'Absent'
}
)
}
}
}
configuration Sample_IisLogging_LogCustomFields_EnsurePresentDefault
{
param
(
# Target nodes to apply the configuration
[String[]] $NodeName = 'localhost'
)
# Import the module that defines custom resources
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
IisLogging Logging
{
LogPath = 'C:\IISLogFiles'
Logflags = @('Date','Time','ClientIP','ServerIP','UserAgent')
LogFormat = 'W3C'
LogTargetW3C = 'File,ETW'
LogCustomFields = @(
DSC_LogCustomField
{
LogFieldName = 'ClientEncoding'
SourceName = 'Accept-Encoding'
SourceType = 'RequestHeader'
}
)
}
}
}
configuration Sample_IisLogging_LogCustomFields_EnsurePresentExplicitly
{
param
(
# Target nodes to apply the configuration
[String[]] $NodeName = 'localhost'
)
# Import the module that defines custom resources
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
IisLogging Logging
{
LogPath = 'C:\IISLogFiles'
Logflags = @('Date','Time','ClientIP','ServerIP','UserAgent')
LogFormat = 'W3C'
LogTargetW3C = 'File,ETW'
LogCustomFields = @(
DSC_LogCustomField
{
LogFieldName = 'ClientEncoding'
SourceName = 'Accept-Encoding'
SourceType = 'RequestHeader'
Ensure = 'Present'
}
)
}
}
}
configuration Sample_IisLogging_LogFlags
{
param
(
# Target nodes to apply the configuration
[String[]] $NodeName = 'localhost'
)
# Import the module that defines custom resources
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
IisLogging Logging
{
LogPath = 'C:\IISLogFiles'
Logflags = @('Date', 'Time', 'ClientIP', 'ServerIP', 'UserAgent')
LogFormat = 'W3C'
}
}
}
configuration Sample_IisLogging_Rollover
{
param
(
# Target nodes to apply the configuration
[String[]] $NodeName = 'localhost'
)
# Import the module that defines custom resources
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
IisLogging Logging
{
LogPath = 'C:\IISLogFiles'
Logflags = @('Date', 'Time', 'ClientIP', 'UserName', 'ServerIP')
LoglocalTimeRollover = $true
LogPeriod = 'Hourly'
LogFormat = 'W3C'
}
}
}
configuration Sample_IisLogging_Truncate
{
param
(
# Target nodes to apply the configuration
[String[]] $NodeName = 'localhost'
)
# Import the module that defines custom resources
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
IisLogging Logging
{
LogPath = 'C:\IISLogFiles'
Logflags = @('Date', 'Time', 'ClientIP', 'UserName', 'ServerIP')
LoglocalTimeRollover = $true
LogTruncateSize = '2097152'
LogFormat = 'W3C'
}
}
}
- Home
- IisFeatureDelegation
- IisLogging
- IisMimeTypeMapping
- IisModule
- SslSettings
- WebApplication
- WebApplicationHandler
- WebAppPool
- WebAppPoolDefaults
- WebConfigProperty
- WebConfigPropertyCollection
- WebSite
- WebSiteDefaults
- WebVirtualDirectory
- xIisFeatureDelegation
- xIisHandler
- xIisLogging
- xIisMimeTypeMapping
- xIisModule
- xSslSettings
- xWebApplication
- xWebAppPool
- xWebAppPoolDefaults
- xWebConfigKeyValue
- xWebConfigProperty
- xWebConfigPropertyCollection
- xWebSite
- xWebSiteDefaults
- xWebVirtualDirectory