> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Logging Overview

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

If you need to monitor your cluster, tune performance, or <InternalLink path="troubleshooting-overview">troubleshoot</InternalLink> issues, you can check the CockroachDB logs, which include details about notable cluster, node, and range-level events.

## Details

When a node starts, shuts down, or processes a <InternalLink path="cockroach-commands">`cockroach` command</InternalLink>, it produces a stream of messages about the command's activities. Each message is composed of:

* A payload that contains events either structured in JSON or conveyed in an arbitrary string. For details on structured event types and their fields, see <InternalLink path="eventlog">Notable Event Types</InternalLink>.
* An envelope that contains event metadata (e.g., severity, date, timestamp, channel). Depending on the log format you specify when <InternalLink path="configure-logs#file-logging-format">configuring logs</InternalLink>, the envelope can be formatted either in JSON or as a flat prefix to the message.

Messages are organized into appropriate [logging channels](#logging-channels) and then routed through log sinks. Each sink further processes and filters the messages before emitting them to destinations outside CockroachDB. The mapping of channels to sinks, as well as the processing and filtering done by each sink, is configurable and is intended to support multiple <InternalLink path="logging-use-cases">use cases</InternalLink>. For more information on configuring sinks and severity levels, see <InternalLink path="configure-logs">Configure Logs</InternalLink>.

<Tip>
  All <InternalLink path="cockroach-commands">`cockroach` commands</InternalLink> support logging. However, note that most messages related to cluster operation are generated by <InternalLink path="cockroach-start">`cockroach start`</InternalLink> or <InternalLink path="cockroach-start-single-node">`cockroach start-single-node`</InternalLink>. Other commands generate messages related to their own execution, which are mainly useful when troubleshooting the behaviors of those commands.
</Tip>

## Logging channels

<Note>
  Log channels cannot be completely disabled. You can configure <InternalLink path="configure-logs#configure-log-sinks">how log messages are routed to different sinks</InternalLink> and <InternalLink path="configure-logs#set-logging-levels">adjust verbosity levels</InternalLink>, but you cannot turn off a log channel entirely. For example, a channel that **is not explicitly configured** for a <InternalLink path="configure-logs#output-to-files">file group</InternalLink> **is enabled** in the `default` file group.
</Note>

Log messages in CockroachDB are directed into logging channels, which can in turn be assigned to output to one or more <InternalLink path="configure-logs#configure-log-sinks">log sinks</InternalLink>.

This allows you to group channels that log related information (e.g., operational, security, or SQL events) into their own sinks. Each sink can output to a predetermined destination where the logs can be collected and parsed. For usage examples, see <InternalLink path="logging-use-cases">Logging Use Cases</InternalLink>.

| Channel                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <InternalLink path="logging#dev">`DEV`</InternalLink>                           | Uncategorized and debug messages.                                                                                                                                                                                                                                                                                                                                                                                          |
| <InternalLink path="logging#ops">`OPS`</InternalLink>                           | Process starts, stops, shutdowns, and crashes (if they can be logged); changes to cluster topology, such as node additions, removals, and decommissions.                                                                                                                                                                                                                                                                   |
| <InternalLink path="logging#health">`HEALTH`</InternalLink>                     | Resource usage; node-node connection events, including connection errors; up- and down-replication and range unavailability.                                                                                                                                                                                                                                                                                               |
| <InternalLink path="logging#storage">`STORAGE`</InternalLink>                   | Low-level storage logs from the <InternalLink path="architecture/storage-layer#pebble">Pebble storage engine</InternalLink>.                                                                                                                                                                                                                                                                                               |
| <InternalLink path="logging#sessions">`SESSIONS`</InternalLink>                 | Client connections and disconnections (when enabled via the `server.auth_log.sql_connections.enabled` <InternalLink path="cluster-settings">cluster setting</InternalLink>); SQL authentication logins/attempts and session/query terminations (when enabled via the `server.auth_log.sql_sessions.enabled` <InternalLink path="cluster-settings">cluster setting</InternalLink>).                                         |
| <InternalLink path="logging#sql_schema">`SQL_SCHEMA`</InternalLink>             | Database, schema, table, sequence, view, and type creation; changes to table columns and sequence parameters.                                                                                                                                                                                                                                                                                                              |
| <InternalLink path="logging#user_admin">`USER_ADMIN`</InternalLink>             | Changes to users, roles, and authentication credentials.                                                                                                                                                                                                                                                                                                                                                                   |
| <InternalLink path="logging#privileges">`PRIVILEGES`</InternalLink>             | Changes to privileges and object ownership.                                                                                                                                                                                                                                                                                                                                                                                |
| <InternalLink path="logging#sensitive_access">`SENSITIVE_ACCESS`</InternalLink> | SQL audit events (when enabled via <InternalLink path="alter-table#experimental_audit">`ALTER TABLE ... EXPERIMENTAL_AUDIT`</InternalLink>).                                                                                                                                                                                                                                                                               |
| <InternalLink path="logging#sql_exec">`SQL_EXEC`</InternalLink>                 | SQL statement executions (when enabled via the `sql.trace.log_statement_execute` <InternalLink path="cluster-settings">cluster setting</InternalLink>) and uncaught Go panic errors during SQL statement execution.<br /><br />**Warning**: Logging cluster-wide executions by enabling the `sql.trace.log_statement_execute` cluster setting will incur considerable overhead and may have a negative performance impact. |
| <InternalLink path="logging#sql_perf">`SQL_PERF`</InternalLink>                 | SQL executions that impact performance, such as slow queries (when enabled via the `sql.log.slow_query.latency_threshold` and/or `sql.log.slow_query.experimental_full_table_scans.enabled` <InternalLink path="cluster-settings">cluster settings</InternalLink>).                                                                                                                                                        |
| <InternalLink path="logging#telemetry">`TELEMETRY`</InternalLink>               | Telemetry events for internal usage, except for <InternalLink path="eventlog#sampled_query">`sampled_query` events</InternalLink> which may be <InternalLink path="log-sql-activity-to-datadog">logged externally to Datadog</InternalLink>.                                                                                                                                                                               |
| <InternalLink path="logging#kv_distribution">`KV_DISTRIBUTION`</InternalLink>   | Data distribution events, such as moving <InternalLink path="architecture/overview">replicas</InternalLink> between <InternalLink path="cockroach-start#store">stores</InternalLink> in a cluster, adding replicas to <InternalLink path="architecture/overview#range">ranges</InternalLink>, and removing replicas from ranges.                                                                                           |

Logging channels are analogous to [logging facilities in Syslog](https://wikipedia.org/wiki/Syslog) or [logging services in Datadog](https://docs.datadoghq.com/logs/log_collection/?tab=http#reserved-attributes). For more details on the contents of each logging channel, see the <InternalLink path="logging#logging-channels">Logging reference</InternalLink>.

## Logging destinations

When using the <InternalLink path="configure-logs#default-logging-configuration">default logging configuration</InternalLink>, the events collected on each [logging channel](#logging-channels) are split into log files as follows:

| Filename                        | Description             | Channels                    |
| ------------------------------- | ----------------------- | --------------------------- |
| `cockroach.log`                 | General CockroachDB log | `DEV`                       |
| `cockroach-health.log`          | Health log              | `HEALTH`                    |
| `cockroach-kv-distribution.log` | Data distribution log   | `KV_DISTRIBUTION`           |
| `cockroach-security.log`        | SQL security log        | `PRIVILEGES` + `USER_ADMIN` |
| `cockroach-sql-audit.log`       | SQL access audit log    | `SENSITIVE_ACCESS`          |
| `cockroach-sql-auth.log`        | SQL authentication log  | `SESSIONS`                  |
| `cockroach-sql-exec.log`        | SQL execution log       | `SQL_EXEC`                  |
| `cockroach-sql-slow.log`        | SQL slow query log      | `SQL_PERF`                  |
| `cockroach-sql-schema.log`      | SQL schema change log   | `SQL_SCHEMA`                |
| `cockroach-pebble.log`          | Pebble log              | `STORAGE`                   |
| `cockroach-telemetry.log`       | Telemetry log           | `TELEMETRY`                 |

Logging destinations and many other parameters are configurable via YAML. For details, see <InternalLink path="configure-logs">Configure Logs</InternalLink>.

## See also

* <InternalLink path="configure-logs">Configure logs</InternalLink>
* <InternalLink path="logging">Logging Levels and Channels</InternalLink>
* <InternalLink path="log-formats">Log formats</InternalLink>
* <InternalLink path="eventlog">Notable Event Types</InternalLink>
