You can use Cloud Logging to view and query logs for your Looker (Google Cloud core) instance. Monitoring these logs helps you troubleshoot issues, track usage, and ensure the health and security of your Looker environment, providing reliable data for your operations. For more details on Cloud Logging, see the [Cloud Logging documentation](https://docs.cloud.google.com/logging/docs.md.txt).

## Required roles

To understand the required roles for Cloud Logging, visit the [Access control with IAM](https://docs.cloud.google.com/logging/docs/access-control.md.txt) page of the Cloud Logging documentation.

## View logs

To view logs for your Looker (Google Cloud core) instance log entries, select one of the following options:

### console


1. In the Google Cloud console, go to **Logging \> Logs Explorer**
2. Select an existing Looker (Google Cloud core) project at the top of the page.
3. In the Query builder, add the following:
   - Resource: Select **Looker instance**. In the dialog, select a Looker (Google Cloud core) instance ID.
   - Log names: Scroll to the Looker section and select appropriate log files for your instance. For example:
     - looker.googleapis.com%2FContentAccess
     - looker.googleapis.com%2FUserLogin
   - Severity: Select a log level.
   - Time range: Select a preset or create a custom range.

<br />

### gcloud


Use the [`gcloud logging`](https://docs.cloud.google.com/sdk/gcloud/reference/logging/read.md.txt)
command to view log entries.

<br />

```bash
gcloud logging read "resource.type=looker.googleapis.com/Instance" \
--project=PROJECT_ID \
--limit=10 \
--format=json
```

Replace the following:

- <var translate="no">PROJECT_ID</var>: the ID of the Google Cloud project in which the Looker (Google Cloud core) instance resides.

You may also include the following flags:

- The [`limit`](https://docs.cloud.google.com/sdk/gcloud/reference/logging/read.md.txt#--limit) flag is an optional parameter that indicates the maximum number of entries to return.

## Troubleshoot

| Issue | Troubleshooting |
|---|---|
| Log files are incomplete. | Check the [severity level](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry.md.txt#logseverity) at which your logging is configured. Log messages below the level configured will be dropped. |
| Operations information is not found in logs. | You want to find more information about an operation. <br /> For example, a user was deleted but you can't find out who did it. The logs show the operation started but don't provide any more information. You must [enable audit logging](https://docs.cloud.google.com/logging/docs/audit.md.txt) for detailed and personal identifying information (PII) like this to be logged. |
| Log files are hard to read. | You'd rather view the logs as JSON or text. You can use the [`gcloud logging read`](https://docs.cloud.google.com/sdk/gcloud/reference/logging/read.md.txt) command along with Linux post-processing commands to download the logs. To download the logs as JSON, use the following code: ```bash gcloud logging read \ "resource.type=looker.googleapis.com/Instance \ AND logName=projects/PROJECT_ID \ /logs/looker.googleapis.com%2FLOG_NAME" \ --format json \ --project=PROJECT_ID \ --freshness="1d" \ > downloaded-log.json ``` Replace the following: - <var translate="no">`PROJECT_ID`</var>: the ID of the Google Cloud project in which the Looker (Google Cloud core) instance resides - <var translate="no">`LOG_NAME`</var>: the resource name of the log To download the logs as text, use the following code: ```bash gcloud logging read \ "resource.type=looker.googleapis.com/Instance \ AND logName=projects/PROJECT_ID \ /logs/looker.googleapis.com%2FLOG_NAME" \ --format json \ --project=PROJECT_ID \ --freshness="1d"| jq -rnc --stream 'fromstream(1|truncate_stream(inputs)) \ | .textPayload' \ --order=asc > downloaded-log.txt ``` Replace the following: - <var translate="no">`PROJECT_ID`</var>: the ID of the Google Cloud project in which the Looker (Google Cloud core) instance resides - <var translate="no">`LOG_NAME`</var>: the resource name of the log |

## What's next

- [Looker (Google Cloud core) audit logging](https://docs.cloud.google.com/looker/docs/looker-core-audit-logging.md.txt)