Module entries (3.12.1)

Log entries within the Google Cloud Logging API.

Classes

LogEntry

LogEntry(log_name=None,labels=None,insert_id=None,severity=None,http_request=None,timestamp=None,resource=Resource(type="global",labels={}),trace=None,span_id=None,trace_sampled=None,source_location=None,operation=None,logger=None,payload=None,)

Log entry.

Parameters
NameDescription
log_namestr

The name of the logger used to post the entry.

labelsOptional[dict]

Mapping of labels for the entry

insert_idOptional[str]

The ID used to identify an entry uniquely.

severityOptional[str]

The severity of the event being logged.

http_requestOptional[dict]

Info about HTTP request associated with the entry.

timestampOptional[datetime.datetime]

Timestamp for the entry.

resourceOptional[google.cloud.logging_v2.resource.Resource]

Monitored resource of the entry.

traceOptional[str]

Trace ID to apply to the entry.

span_idOptional[str]

Span ID within the trace for the log entry. Specify the trace parameter ifspan_id is set.

trace_sampledOptional[bool]

The sampling decision of the trace associated with the log entry.

source_locationOptional[dict]

Location in source code from which the entry was emitted.

operationOptional[dict]

Additional information about a potentially long-running operation associated with the log entry.

loggerlogging_v2.logger.Logger See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

the logger used to write the entry.

ProtobufEntry

ProtobufEntry(log_name=None,labels=None,insert_id=None,severity=None,http_request=None,timestamp=None,resource=Resource(type="global",labels={}),trace=None,span_id=None,trace_sampled=None,source_location=None,operation=None,logger=None,payload=None,)

Log entry with protobuf message payload.

Parameters
NameDescription
log_namestr

The name of the logger used to post the entry.

labelsOptional[dict]

Mapping of labels for the entry

insert_idOptional[str]

The ID used to identify an entry uniquely.

severityOptional[str]

The severity of the event being logged.

http_requestOptional[dict]

Info about HTTP request associated with the entry.

timestampOptional[datetime.datetime]

Timestamp for the entry.

resourceOptional[google.cloud.logging_v2.resource.Resource]

Monitored resource of the entry.

traceOptional[str]

Trace ID to apply to the entry.

span_idOptional[str]

Span ID within the trace for the log entry. Specify the trace parameter ifspan_id is set.

trace_sampledOptional[bool]

The sampling decision of the trace associated with the log entry.

source_locationOptional[dict]

Location in source code from which the entry was emitted.

operationOptional[dict]

Additional information about a potentially long-running operation associated with the log entry.

loggerlogging_v2.logger.Logger

the logger used to write the entry.

payloadgoogle.protobuf.Message See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

payload for the log entry.

StructEntry

StructEntry(log_name=None,labels=None,insert_id=None,severity=None,http_request=None,timestamp=None,resource=Resource(type="global",labels={}),trace=None,span_id=None,trace_sampled=None,source_location=None,operation=None,logger=None,payload=None,)

Log entry with JSON payload.

Parameters
NameDescription
log_namestr

The name of the logger used to post the entry.

labelsOptional[dict]

Mapping of labels for the entry

insert_idOptional[str]

The ID used to identify an entry uniquely.

severityOptional[str]

The severity of the event being logged.

http_requestOptional[dict]

Info about HTTP request associated with the entry.

timestampOptional[datetime.datetime]

Timestamp for the entry.

resourceOptional[google.cloud.logging_v2.resource.Resource]

Monitored resource of the entry.

traceOptional[str]

Trace ID to apply to the entry.

span_idOptional[str]

Span ID within the trace for the log entry. Specify the trace parameter ifspan_id is set.

trace_sampledOptional[bool]

The sampling decision of the trace associated with the log entry.

source_locationOptional[dict]

Location in source code from which the entry was emitted.

operationOptional[dict]

Additional information about a potentially long-running operation associated with the log entry.

loggerlogging_v2.logger.Logger

the logger used to write the entry.

payloaddict See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

payload for the log entry.

TextEntry

TextEntry(log_name=None,labels=None,insert_id=None,severity=None,http_request=None,timestamp=None,resource=Resource(type="global",labels={}),trace=None,span_id=None,trace_sampled=None,source_location=None,operation=None,logger=None,payload=None,)

Log entry with text payload.

Parameters
NameDescription
log_namestr

The name of the logger used to post the entry.

labelsOptional[dict]

Mapping of labels for the entry

insert_idOptional[str]

The ID used to identify an entry uniquely.

severityOptional[str]

The severity of the event being logged.

http_requestOptional[dict]

Info about HTTP request associated with the entry.

timestampOptional[datetime.datetime]

Timestamp for the entry.

resourceOptional[google.cloud.logging_v2.resource.Resource]

Monitored resource of the entry.

traceOptional[str]

Trace ID to apply to the entry.

span_idOptional[str]

Span ID within the trace for the log entry. Specify the trace parameter ifspan_id is set.

trace_sampledOptional[bool]

The sampling decision of the trace associated with the log entry.

source_locationOptional[dict]

Location in source code from which the entry was emitted.

operationOptional[dict]

Additional information about a potentially long-running operation associated with the log entry.

loggerlogging_v2.logger.Logger

the logger used to write the entry.

payloadstr See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

payload for the log entry.

Modules Functions

logger_name_from_path

logger_name_from_path(path,project=None)

Validate a logger URI path and get the logger name.

Parameters
NameDescription
pathstr

URI path for a logger API request

projectstr

The project the path is expected to belong to

Exceptions
TypeDescription
ValueErrorIf thepath is ill-formed of if the project frompath does not agree with theproject passed in.
Returns
TypeDescription
strLogger name parsed frompath.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.