Skip to content

Enable-PodeLogRequestType

SYNOPSIS

Enables Request Logging using a supplied output method.

SYNTAX

ScriptBlock (Default)

Enable-PodeLogRequestType [-Name <String>] -Method <String[]> [-UsernameProperty <String>] [-Format <String>]
 [-W3CInfo <Hashtable>] [-LogFormat <PodeLogFormat>] [-LogScriptBlock <ScriptBlock>]
 [-SerialiseFormat <PodeSerialiseFormat>] [-SerialiseScriptBlock <ScriptBlock>] [-ScriptBlock <ScriptBlock>]
 [-ArgumentList <Object[]>] [-SyslogInfo <Hashtable>] [-RemoteIPHeader <String[]>] [-AsUtc]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

Raw

Enable-PodeLogRequestType [-Name <String>] -Method <String[]> [-UsernameProperty <String>] [-Format <String>]
 [-W3CInfo <Hashtable>] [-LogFormat <PodeLogFormat>] [-LogScriptBlock <ScriptBlock>]
 [-SerialiseFormat <PodeSerialiseFormat>] [-SerialiseScriptBlock <ScriptBlock>] [-SyslogInfo <Hashtable>]
 [-RemoteIPHeader <String[]>] [-AsUtc] [-Raw] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Enables Request Logging using a supplied output method.

EXAMPLES

EXAMPLE 1

New-PodeLogTerminalMethod | Enable-PodeLogRequestType

EXAMPLE 2

New-PodeLogTerminalMethod | Enable-PodeLogRequestType -AsUtc

EXAMPLE 3

New-PodeLogTerminalMethod | Enable-PodeLogRequestType -RemoteIPHeader 'X-Forwarded-For'

EXAMPLE 4

New-PodeLogTerminalMethod | Enable-PodeLogRequestType -Name 'custom-req' -SerialiseFormat 'Json'

EXAMPLE 5

New-PodeLogTerminalMethod | Enable-PodeLogRequestType -SerialiseFormat 'Custom' -SerialiseScriptBlock {
    param($data)
    return "$($data.Host) $($data.Identifier) $($data.User) [$($data.Date)] `"$($data.RequestLine)`" $($data.StatusCode) $($data.Size) `"$($data.Referrer)`" `"$($data.UserAgent)`""
}

EXAMPLE 6

New-PodeLogTerminalMethod | Enable-PodeLogRequestType -ScriptBlock {
    param($logEvent)
    return @{
        HttpMethod = $logEvent.Data.HttpMethod
    }
}

EXAMPLE 7

$syslogInfo = New-PodeLogSyslogInfo -Format RFC3164
New-PodeLogTerminalMethod | Enable-PodeLogRequestType -LogFormat Syslog -SyslogInfo $syslogInfo

PARAMETERS

-ArgumentList

An array of arguments to supply to the Custom Log Type's ScriptBlock and SerialiseScriptBlock.

Type: Object[]
Parameter Sets: ScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AsUtc

If supplied, the log entry's timestamp will be in UTC, otherwise it will be in local time.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Format

The format to use for the log output. (Default: Combined)

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Combined
Accept pipeline input: False
Accept wildcard characters: False

-LogFormat

The format to use for the log output. (Default: Server default, or 'None' if no default set).

Type: PodeLogFormat
Parameter Sets: (All)
Aliases:
Accepted values: None, Custom, Syslog

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-LogScriptBlock

A ScriptBlock to use for custom log formatting of the log entry.

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Method

One or more Log Method IDs to use for outputting the log entry.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Name

An optional Name to assign to the Request Log Type. If not supplied, a default name will be used.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Raw

If supplied, the log item returned will be the raw Request item as a hashtable and not a string (for Custom methods).

Type: SwitchParameter
Parameter Sets: Raw
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-RemoteIPHeader

One or more optional headers to check for the client's remote IP address, if behind a reverse proxy.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ScriptBlock

A ScriptBlock to use for custom data selection and transforming of the log entry. (Default: inbuilt logic).

Type: ScriptBlock
Parameter Sets: ScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SerialiseFormat

Specifies the format to use for serialising the log entry. (Default: Server default, or 'Custom' if no default set, or 'None' if Raw is supplied).

Type: PodeSerialiseFormat
Parameter Sets: (All)
Aliases:
Accepted values: None, Custom, Json, Xml, Yaml

Required: False
Position: Named
Default value: Custom
Accept pipeline input: False
Accept wildcard characters: False

-SerialiseScriptBlock

A ScriptBlock to use for custom serialisation of the log entry.

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SyslogInfo

A hashtable containing Syslog configuration information, built using New-PodeSyslogInfo.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UsernameProperty

An optional property path within the $WebEvent.Auth.User object for the user's Username. (Default: Username).

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-W3CInfo

An optional hashtable of W3C log configuration information, built using New-PodeLogW3CInfo. If not supplied, but -Format=W3C, then default W3C fields will be used.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES