< Back

New-GcLogEntry

Mon Jan 13, 2020 11:28 pm

NAME New-GcLogEntry



SYNOPSIS

Creates new log entries.





SYNTAX

New-GcLogEntry [-Project <string>] [-LogName] <string> -TextPayload <string[]> [-Severity {Default | Debug | Info

| Notice | Warning | Error | Critical | Alert | Emergency}] [-MonitoredResource <MonitoredResource>]

[<CommonParameters>]



New-GcLogEntry [-Project <string>] [-LogName] <string> -JsonPayload <Hashtable[]> [-Severity {Default | Debug |

Info | Notice | Warning | Error | Critical | Alert | Emergency}] [-MonitoredResource <MonitoredResource>]

[<CommonParameters>]



New-GcLogEntry [-Project <string>] [-LogName] <string> -ProtoPayload <Hashtable[]> [-Severity {Default | Debug |

Info | Notice | Warning | Error | Critical | Alert | Emergency}] [-MonitoredResource <MonitoredResource>]

[<CommonParameters>]





DESCRIPTION

Creates new log entries in a log. The cmdlet will create the log if it doesn't exist. By default, the log is

associated with the "global" resource type ("custom.googleapis.com" in v1 service).





PARAMETERS

-Project <string>

The project to where the log entry will be written to. If not set via PowerShell parameter processing, will

default to the Cloud SDK's DefaultProject property.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-LogName <string>

The name of the log that this entry will be written to. If the log does not exist, it will be created.



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-TextPayload <string[]>

The text payload of the log entry. Each value in the array will be written to a single entry in the log.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-JsonPayload <Hashtable[]>

The JSON payload of the log entry. Each value in the array will be written to a single entry in the log.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-ProtoPayload <Hashtable[]>

The proto payload of the log entry. Each value in the array will be written to a single entry in the log.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Severity <LogSeverity>

The severity of the log entry. Default value is Default.



Possible values: Default, Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency



Required? false

Position? named

Default value Default

Accept pipeline input? false

Accept wildcard characters? false



-MonitoredResource <MonitoredResource>

Monitored Resource associated with the log. If not provided, we will default to "global" resource type

("custom.googleapis.com" in v1 service). This is what gcloud beta logging write uses. This indicates that the

log is not associated with any specific resource. More information can be found at

https://cloud.google.com/logging/docs/a ... ource-list



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String[]

The text payload of the log entry. Each value in the array will be written to a single entry in the log.



System.Collections.Hashtable[]

The JSON payload of the log entry. Each value in the array will be written to a single entry in the log.





OUTPUTS



---------- EXAMPLE 1 ----------



PS C:\\> New-GcLogEntry -TextPayload "This is a log entry." -LogName "test-log"



This command creates a log entry with the specified text payload in the log "test-log".

---------- EXAMPLE 2 ----------



PS C:\\> New-GcLogEntry -TextPayload "Entry 1", "Entry 2" -LogName "test-log"



This command creates 2 log entries with text payload "Entry 1" and "Entry 2" respectively in the log "test-log".

---------- EXAMPLE 3 ----------



PS C:\\> New-GcLogEntry -JsonPayload @{"a" = "b"} -LogName "test-log" -Severity Error



This command creates a log entry with a json payload and severity level Error in the log "test-log".

---------- EXAMPLE 4 ----------



PS C:\\> New-GcLogEntry -MonitoredResource (New-GcLogMonitoredResource -ResourceType global -Labels @{"project_id"

= "my-project"}) `

-TextPayload "This is a log entry."



This command creates a log entry directly from the LogEntry object. The command also associates it with a resource

type created from New-GcLogMonitoredResource



RELATED LINKS

[Log Entries and Logs] (https://cloud.google.com/logging/docs/view/logs_index)

[Monitored Resources] (https://cloud.google.com/logging/docs/a ... ource-list)