Class LogEntry (3.0.0)

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

Name Description
log_name str

The name of the logger used to post the entry.

labels Optional[dict]

Mapping of labels for the entry

insert_id Optional[str]

The ID used to identify an entry uniquely.

severity Optional[str]

The severity of the event being logged.

http_request Optional[dict]

Info about HTTP request associated with the entry.

timestamp Optional[datetime.datetime]

Timestamp for the entry.

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

Monitored resource of the entry.

trace Optional[str]

Trace ID to apply to the entry.

span_id Optional[str]

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

trace_sampled Optional[bool]

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

source_location Optional[dict]

Location in source code from which the entry was emitted.

operation Optional[dict]

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

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

the logger used to write the entry.

Methods

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,
)

Create new instance of LogEntry(log_name, labels, insert_id, severity, http_request, timestamp, resource, trace, span_id, trace_sampled, source_location, operation, logger, payload)

from_api_repr

from_api_repr(resource, client, *, loggers=None)

Construct an entry given its API representation

Parameters
Name Description
resource dict

text entry resource representation returned from the API

client logging_v2.client.Client

Client which holds credentials and project configuration.

loggers Optional[dict]

A mapping of logger fullnames -> loggers. If not passed, the entry will have a newly-created logger if possible, or an empty logger field if not.

Returns
Type Description
google.cloud.logging.entries.LogEntry Log entry parsed from resource.

to_api_repr

to_api_repr()

API repr (JSON format) for entry.

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

Last updated 2025年10月30日 UTC.