Mainframe Connector can send JSON formatted log messages containing
context information to Cloud Logging. The context includes job name, job ID,
job date, step name, and other variables provided by z/OS.

This helps you find logs for specific jobs and create alerts. Additionally,
when deploying Mainframe Connector on Cloud Run,
Google Kubernetes Engine, or Compute Engine, the logs are collected by the
Cloud Logging agent and appear in Logs Explorer.

## Configure Cloud Logging in JCL

To configure Mainframe Connector to write to Cloud Logging, set the
`LOG_PROJECT` and `LOG_ID` environment variables in the
JCL that launches the job.

    LOG_PROJECT=PROJECT_ID
    LOG_ID=LOG_ID

Replace the following:

- `PROJECT_ID`: the name of the Google Cloud project where you want to store the logs. For example, `mainframe-connector-proj`.
- `LOG_ID`: an identifier for your log stream. For example, `my-mfc`.

The log name (`LOG_NAME`) is derived from `LOG_PROJECT`
and `LOG_ID`. In this example, the log name is:

    projects/mainframe-connector-proj/logs/my-mfc

The resource type is always *global* because the log is a
user-created log rather than a service-managed log. During startup,
Mainframe Connector displays a message indicating whether
Cloud Logging is configured.

## View logs in Logs Explorer

After configuring Cloud Logging, you can search and filter your logs in
Logs Explorer:

1. In the Google Cloud console, go to the **Logs Explorer** page.

   [Go to Logs Explorer](https://console.cloud.google.com/logs/query)
2. In the query pane, filter by resource type **Global** or by your log name:

       logName="projects/PROJECT_ID/logs/LOG_ID"

## What's next

- [Monitor Mainframe Connector
  performance](https://docs.cloud.google.com/mainframe-connector/docs/monitor-performance)
- [Publish messages to Pub/Sub from your
  mainframe](https://docs.cloud.google.com/mainframe-connector/docs/pub-sub)
- [Run Cloud Run jobs using
  Mainframe Connector](https://docs.cloud.google.com/mainframe-connector/docs/run-jobs)