You can access event logs for your integrations from
[Google Cloud Logging](https://cloud.google.com/logging).
Use Cloud Logging to explore logs, create metrics and alerts, or
export logs to other applications using
[Google Cloud Pub/Sub](https://cloud.google.com/pubsub).

## Access Logging

To access Cloud Logging from the
[Google Cloud Console](https://console.cloud.google.com/),
click **View all products** , then go to **Observability** \> **Logging**.

[Go to Cloud Logging](https://console.cloud.google.com/logs)

Access to logging data is managed through Identity and Access Management (IAM)
for users of your Actions project. For more details on roles and permissions for
logging data, see Cloud Logging
[access control](https://cloud.google.com/logging/docs/access-control).

Log entries are retained for 30 days per the Cloud Logging
[retention policy](https://cloud.google.com/logging/quotas), then
scheduled for deletion. You can also delete entries on demand by using the
Logs Explorer interface.

You can learn more on how to use logs effectively in the Searching Logs section
of the [Troubleshooting guide](https://developers.home.google.com/cloud-to-cloud/analytics/troubleshooting).

Cloud Logging provides the following resource types:

| Resource Type | Display Name | Description | Labels |
|---|---|---|---|
| `assistant_action_project` | Google Assistant Action Project | A container for the Google Cloud Project associated with an Assistant Action. | - `project_id`: The identifier of your current project that's associated with this resource, for example `my-project`. |

## Event logs

Cloud-to-cloud projects support the following events in Cloud
Logging:

| Cloud Logging Resource | Event |
|---|---|
| Google Assistant Action Project | [SYNC](https://developers.home.google.com/cloud-to-cloud/primer/intents#sync) intent errors |
| Google Assistant Action Project | [QUERY](https://developers.home.google.com/cloud-to-cloud/primer/intents#query) intent errors |
| Google Assistant Action Project | [EXECUTE](https://developers.home.google.com/cloud-to-cloud/primer/intents#execute) intent errors |
| Google Assistant Action Project | [Notifications](https://developers.home.google.com/cloud-to-cloud/integration/notifications) errors |
| Google Assistant Action Project | [Account linking](https://developers.home.google.com/cloud-to-cloud/primer/account-linking) errors |
| Google Assistant Action Project | Local Home SDK [HandlerError](https://developers.home.google.com/reference/local-home/classes/smarthome.intentflow.handlererror) |

## Sync logs

The table below lists the schema of a `syncLog` entry:

| Property | Description |
|---|---|
| `requestId` | Smart home intent request ID. |
| `httpLatencyMsec` | Elapsed time before a response was received. |
| `status` | Indicates the status of the intent response. |

## Execution logs

The table below lists the schema of an `executionLog` entry:

| Property | Description |
|---|---|
| `requestId` | Unique request ID, for example `5325511189174727525`. |
| `latencyMsec` | Elapsed time before a response was received, for example, `6000`. |
| `executionType` | Transport used for the request, for example `CLOUD` or `MATTER`, depending on your integration. |
| `actionType` | Optional indicator of the user action taken, for example `QUERY` or `EXECUTE`. For `EXECUTE` actions, includes the command issued to fulfillment for supported traits, for example `ONOFF_OFF` |
| `trait` | Optional trait associated with this user action. |
| `deviceTypes` | List of device types affected by the event, for example `LIGHT`. |
| `isSuccess` | Whether the request received a successful response. |
| `fallbackToCloud` | Whether the request routed to cloud fulfillment following an error from local fulfillment. |
| `statusType` | Indicates the status of the intent response, such as `SUCCESS`, `PENDING`, or `OFFLINE`. For `ERROR` responses, this property contains the `errorCode` provided by the fulfillment. |
| `externalDebugString` | Optional detailed debugging message associated with this user action. |
| `locale` | Language code associated with the request. |

## Notification logs

The table below lists the schema of a `notificationLog` entry:

| Property | Description |
|---|---|
| `requestId` | Notification request ID. |
| `structName` | Name of the notification struct, such as "ObjectDetection". |
| `status` | Indicates the [status](https://developers.home.google.com/cloud-to-cloud/integration/notifications#example-statuses) of the notification. |

## Log level setting

Cloud-to-cloud projects are set to receive error logs by default,
and it is possible for developers to opt-in to receive success logs as well.
This is especially useful during the development phase when you plan to capture
all logs from a few agents. Additional charges may apply to your project if you
exceed the
[logging quota](https://cloud.google.com/stackdriver/pricing).

You can control the log level for your project by:

1. In the Actions on Google Console, go to the Projects page.

   [Go to the Actions on Google console](https://console.actions.google.com)
2. Select your smart home project.

3. Choose the **Develop** tab, and click **Actions** on the side bar.

4. Select **All** in the **Log control ingestion** dropdown list.

## Log exclusions

Developers can create
[log exclusions](https://cloud.google.com/logging/docs/exclusions)
using [logging query
language](https://cloud.google.com/logging/docs/view/logging-query-language)
to further customize their logs in a more flexible way. Logging query language
is also used by Logs Explorer so you can use Logs Explorer to help create
queries.

You can follow the steps for creating exclusion filters at
[this guide](https://cloud.google.com/logging/docs/exclusions#create-filter-existing)
(configure the exclusion filter for the `_Default` sink).

## Log-based metrics

Developers can use
[Log-based metrics](https://cloud.google.com/logging/docs/logs-based-metrics/#user-metrics)
to track and analyze patterns within their logs. It is also possible to
[create custom charts](https://cloud.google.com/logging/docs/logs-based-metrics/charts-and-alerts#create-chart)
and [set up alerts](https://cloud.google.com/logging/docs/logs-based-metrics/charts-and-alerts#alert-on-lbm)
on log-based metrics.

To start using log-based metrics for smart home, check out
[creating a counter log-based metric guide](https://cloud.google.com/logging/docs/logs-based-metrics/counter-metrics).

## Related resources

To learn more about using Cloud Logging in your project, see the following
[documentation](https://cloud.google.com/logging/docs):

- [Pricing](https://cloud.google.com/stackdriver/pricing): Details on allotments and overage costs.
- [Quotas and limits](https://cloud.google.com/logging/quotas): Details on limits and retention policies for logging usage.
- [Advanced logs queries](https://cloud.google.com/logging/docs/view/advanced-queries): Guide to using advanced expressions to query and analyze log data.