Skip to content

Write-PodeErrorLog

SYNOPSIS

Writes and Exception or ErrorRecord using the inbuilt error logging.

SYNTAX

Exception

Write-PodeErrorLog -Exception <Exception> [-Level <String>] [-Metadata <Hashtable>] [-Override <Hashtable[]>]
 [-CheckInnerException] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Error

Write-PodeErrorLog -ErrorRecord <ErrorRecord> [-Level <String>] [-Metadata <Hashtable>]
 [-Override <Hashtable[]>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Message

Write-PodeErrorLog -Message <String> [-Level <String>] [-Metadata <Hashtable>] [-Override <Hashtable[]>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Writes and Exception or ErrorRecord using the inbuilt error logging.

EXAMPLES

EXAMPLE 1

try { /* logic */ } catch { $_ | Write-PodeErrorLog }

EXAMPLE 2

[System.Exception]::new('error message') | Write-PodeErrorLog

EXAMPLE 3

Write-PodeErrorLog -Message 'error message' -Level 'Warning'

EXAMPLE 4

Write-PodeErrorLog -Message 'error message' -Override @(New-PodeLogEventViewerOverride -EventId 1337)

PARAMETERS

-CheckInnerException

If supplied, any exceptions are check for inner exceptions. If one is present, this is also logged.

Type: SwitchParameter
Parameter Sets: Exception
Aliases:

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

-ErrorRecord

An ErrorRecord to write.

Type: ErrorRecord
Parameter Sets: Error
Aliases:

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

-Exception

An Exception to write.

Type: Exception
Parameter Sets: Exception
Aliases:

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

-Level

The Level of the error being logged. (Default: Error)

Type: String
Parameter Sets: (All)
Aliases:

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

-Message

A Message to write.

Type: String
Parameter Sets: Message
Aliases:

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

-Metadata

An optional hashtable of Metadata to include with the log item.

Type: Hashtable
Parameter Sets: (All)
Aliases:

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

-Override

An optional array of override options, to override certain properties of log methods. Created using the New-PodeLogEventViewerOverride, etc. functions.

Type: Hashtable[]
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

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