grace_period (Optional[float]) – The amount of time to wait for pending logs to
be submitted when the process is shutting down.
batch_size (Optional[int]) – The maximum number of items to send at a time in the
background thread.
max_latency (Optional[float]) – The amount of time to wait for new logs before
sending a new batch. It is strongly recommended to keep this smaller
than the grace_period. This means this is effectively the longest
amount of time the background thread will hold onto log entries
before sending them to the server.
resource (Optional[Resource|dict]) – The default monitored resource to associate
with logs when not specified
close()
Closes the worker thread.
flush()
Submit any pending log records.
send(record, message, **kwargs)
Overrides Transport.send().
Parameters
record (logging.LogRecord) – Python log record that the handler was called with.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [3.12.1 (latest)](/python/docs/reference/logging/latest/transport)\n- [3.12.0](/python/docs/reference/logging/3.12.0/transport)\n- [3.11.3](/python/docs/reference/logging/3.11.3/transport)\n- [3.10.0](/python/docs/reference/logging/3.10.0/transport)\n- [3.9.0](/python/docs/reference/logging/3.9.0/transport)\n- [3.8.0](/python/docs/reference/logging/3.8.0/transport)\n- [3.7.0](/python/docs/reference/logging/3.7.0/transport)\n- [3.6.0](/python/docs/reference/logging/3.6.0/transport)\n- [3.5.0](/python/docs/reference/logging/3.5.0/transport)\n- [3.4.0](/python/docs/reference/logging/3.4.0/transport)\n- [3.3.1](/python/docs/reference/logging/3.3.1/transport)\n- [3.2.5](/python/docs/reference/logging/3.2.5/transport)\n- [3.1.2](/python/docs/reference/logging/3.1.2/transport)\n- [3.0.0](/python/docs/reference/logging/3.0.0/transport)\n- [2.7.2](/python/docs/reference/logging/2.7.2/transport)\n- [2.6.0](/python/docs/reference/logging/2.6.0/transport)\n- [2.5.0](/python/docs/reference/logging/2.5.0/transport)\n- [2.4.0](/python/docs/reference/logging/2.4.0/transport)\n- [2.3.1](/python/docs/reference/logging/2.3.1/transport)\n- [2.2.0](/python/docs/reference/logging/2.2.0/transport)\n- [2.1.1](/python/docs/reference/logging/2.1.1/transport)\n- [2.0.2](/python/docs/reference/logging/2.0.2/transport)\n- [1.15.3](/python/docs/reference/logging/1.15.3/transport)\n- [1.14.0](/python/docs/reference/logging/1.14.0/transport)\n- [1.13.0](/python/docs/reference/logging/1.13.0/transport)\n- [1.12.1](/python/docs/reference/logging/1.12.1/transport) \n\nTransports\n==========\n\nThese classes define how the [`CloudLoggingHandler`](/python/docs/reference/logging/latest/handlers-cloud-logging#google.cloud.logging_v2.handlers.handlers.CloudLoggingHandler)\ntransport logs into GCP. More information in the [User Guide](/python/docs/reference/logging/latest/std-lib-integration#transports)\n\nBase Transport\n--------------\n\nModule containing base class for logging transport.\n\n### *class* google.cloud.logging_v2.handlers.transports.base.Transport(client, name, resource=Resource(type='global', labels={}), \\*\\*kwargs)\n\nBases: [`object`](https://docs.python.org/3/library/functions.html#object)\n\nBase class for Google Cloud Logging handler transports.\n\nSubclasses of `Transport` must have constructors that accept a\nclient and name object, and must override `send()`.\n\n- **Parameters**\n\n - **client** ([*Client*](/python/docs/reference/logging/latest/client#google.cloud.logging_v2.client.Client)) -- The Logging client.\n\n - **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The name of the lgoger.\n\n - **resource** (*Optional* *\\[* [*Resource*](/python/docs/reference/logging/latest/resource#google.cloud.logging_v2.resource.Resource)*\\|* [*dict*](https://docs.python.org/3/library/stdtypes.html#dict)*\\]*) -- The default monitored resource to associate\n with logs when not specified\n\n#### close()\n\nCloses the transport and cleans up resources used by it.\n\nThis call should be followed up by disowning the transport.\n\n#### flush()\n\nSubmit any pending log records.\n\nFor blocking/sync transports, this is a no-op.\n\n#### send(record, message, \\*\\*kwargs)\n\nTransport send to be implemented by subclasses.\n\n- **Parameters**\n\n - **record** ([*logging.LogRecord*](https://docs.python.org/3/library/logging.html#logging.LogRecord)) -- Python log record that the handler was called with.\n\n - **message** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)\\* or *\\[* dict\\*\\](\u003chttps://docs.python.org/3/library/stdtypes.html#dict\u003e)) -- The message from the `LogRecord` after being\n formatted by the associated log formatters.\n\n - **kwargs** -- Additional optional arguments for the logger\n\nBackground Thread Transport\n---------------------------\n\nTransport for Python logging handler\n\nUses a background worker to log to Cloud Logging asynchronously.\n\n### *class* google.cloud.logging_v2.handlers.transports.background_thread.BackgroundThreadTransport(client, name, \\*, grace_period=5.0, batch_size=10, max_latency=0, resource=Resource(type='global', labels={}), \\*\\*kwargs)\n\nBases: `google.cloud.logging_v2.handlers.transports.base.Transport`\n\nAsynchronous transport that uses a background thread.\n\n- **Parameters**\n\n - **client** ([*Client*](/python/docs/reference/logging/latest/client#google.cloud.logging_v2.client.Client)) -- The Logging client.\n\n - **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The name of the lgoger.\n\n - **grace_period** (*Optional* *\\[* [*float*](https://docs.python.org/3/library/functions.html#float)*\\]*) -- The amount of time to wait for pending logs to\n be submitted when the process is shutting down.\n\n - **batch_size** (*Optional* *\\[* [*int*](https://docs.python.org/3/library/functions.html#int)*\\]*) -- The maximum number of items to send at a time in the\n background thread.\n\n - **max_latency** (*Optional* *\\[* [*float*](https://docs.python.org/3/library/functions.html#float)*\\]*) -- The amount of time to wait for new logs before\n sending a new batch. It is strongly recommended to keep this smaller\n than the grace_period. This means this is effectively the longest\n amount of time the background thread will hold onto log entries\n before sending them to the server.\n\n - **resource** (*Optional* *\\[* [*Resource*](/python/docs/reference/logging/latest/resource#google.cloud.logging_v2.resource.Resource)*\\|* [*dict*](https://docs.python.org/3/library/stdtypes.html#dict)*\\]*) -- The default monitored resource to associate\n with logs when not specified\n\n#### close()\n\nCloses the worker thread.\n\n#### flush()\n\nSubmit any pending log records.\n\n#### send(record, message, \\*\\*kwargs)\n\nOverrides Transport.send().\n\n- **Parameters**\n\n - **record** ([*logging.LogRecord*](https://docs.python.org/3/library/logging.html#logging.LogRecord)) -- Python log record that the handler was called with.\n\n - **message** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)\\* or *\\[* dict\\*\\](\u003chttps://docs.python.org/3/library/stdtypes.html#dict\u003e)) -- The message from the `LogRecord` after being\n formatted by the associated log formatters.\n\n - **kwargs** -- Additional optional arguments for the logger\n\nSynchronous Transport\n---------------------\n\nTransport for Python logging handler.\n\nLogs directly to the Cloud Logging API with a synchronous call.\n\n### *class* google.cloud.logging_v2.handlers.transports.sync.SyncTransport(client, name, resource=Resource(type='global', labels={}), \\*\\*kwargs)\n\nBases: `google.cloud.logging_v2.handlers.transports.base.Transport`\n\nBasic sychronous transport.\n\nUses this library's Logging client to directly make the API call.\n\n- **Parameters**\n\n - **client** ([*Client*](/python/docs/reference/logging/latest/client#google.cloud.logging_v2.client.Client)) -- The Logging client.\n\n - **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The name of the lgoger.\n\n - **resource** (*Optional* *\\[* [*Resource*](/python/docs/reference/logging/latest/resource#google.cloud.logging_v2.resource.Resource)*\\|* [*dict*](https://docs.python.org/3/library/stdtypes.html#dict)*\\]*) -- The default monitored resource to associate\n with logs when not specified\n\n#### close()\n\nCloses the transport and cleans up resources used by it.\n\nThis call is usually followed up by cleaning up the reference to the transport.\n\n#### send(record, message, \\*\\*kwargs)\n\nOverrides transport.send().\n\n- **Parameters**\n\n - **record** ([*logging.LogRecord*](https://docs.python.org/3/library/logging.html#logging.LogRecord)) -- Python log record that the handler was called with.\n\n - **message** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)\\* or *\\[* dict\\*\\](\u003chttps://docs.python.org/3/library/stdtypes.html#dict\u003e)) -- The message from the `LogRecord` after being\n formatted by the associated log formatters.\n\n - **kwargs** -- Additional optional arguments for the logger"]]