Skip to main content

Gelf

Gelf

Graylog logging format, used to send rich log messages to a Graylog server or other log management system using the Gelf protocol.

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
ServerStringYesN/ADefines the servername of the Graylog server
PortIntYesN/ADefines the port number of the Gelf Input
HostNameStringNo$env:hostnameDefines the hostname of the server running the script
FormatStringNoDefault FormatDefines a custom format for the target
ProtocolStringNo'TCP'Defines if the Gelf input is UDP or TCP
AdditionalFieldHashtableNo$nullOptionally pass on additional static values for the log item

Example

Add-LoggingTarget -Name Gelf -Configuration @{
Level = 'DEBUG'
Server = 'graylog.contoso.com'
Port = 12202
Hostname = 'scriptserver.contoso.com'
Format = '%{message}'
Protocol = 'UDP'
AdditionalFields = @{
Month = (Get-Date).ToString('MMM')
}
}

Write-Log -Level 'WARNING' -Message 'Hello, Powershell!'