Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cockroachdb/cockroach/llms.txt
Use this file to discover all available pages before exploring further.
Overview
CockroachDB provides comprehensive logging capabilities for debugging, auditing, and monitoring. Logs can be written to files, stderr, or external systems, with fine-grained control over verbosity, channels, and formats.Log Configuration
Basic Log Configuration
Configure logging using the--log flag:
Log Configuration Format
The--log flag accepts YAML configuration:
Log Channels
CockroachDB organizes logs into channels based on their purpose:Log Channels
Log Channels
| Channel | Purpose | Examples |
|---|---|---|
DEV | Development events | Debug information, internal state |
OPS | Operational events | Node start/stop, configuration changes |
HEALTH | Health checks | Liveness checks, node availability |
STORAGE | Storage layer | Compaction, disk I/O, store operations |
SESSIONS | SQL sessions | Connection events, authentication |
SQL_SCHEMA | Schema changes | DDL operations, schema migrations |
SQL_EXEC | SQL execution | Query execution, statement logs |
SQL_PERF | SQL performance | Slow queries, execution statistics |
SQL_INTERNAL_PERF | Internal SQL | Background SQL operations |
PRIVILEGES | Security | Permission checks, role changes |
SENSITIVE_ACCESS | Data access | Audit trail for sensitive data |
Configuring Channels
Route specific channels to different outputs:Log Levels
CockroachDB supports standard log levels (verbosity):| Level | Severity | When to Use |
|---|---|---|
NONE | Silent | Disable logging |
FATAL | Critical errors | Process-terminating errors |
ERROR | Errors | Errors that don’t terminate process |
WARNING | Warnings | Potential issues |
INFO | Information | Standard operational messages |
DEBUG | Debug | Detailed debugging information |
Setting Log Level
Log Destinations
File Logging
Default file logging configuration:Log files automatically rotate when they reach the configured size limit (default 10MB).
Stderr Logging
Output logs to standard error:- Container deployments (Docker, Kubernetes)
- Development environments
- Systemd integration with journal
Syslog Integration
Send logs to syslog:Log File Management
Log Rotation
Configure automatic log rotation:max-file-size: Maximum size of a single log file (default 10MB)max-group-size: Maximum combined size for a log group (default 100MB)- Old files are renamed with timestamps
- Oldest files deleted when group size exceeded
Log File Format
Log entries use a structured format:I: Log level (I=INFO, W=WARNING, E=ERROR, F=FATAL)220303: Date (YYMMDD)15:42:17.123456: Time with microseconds1234: Goroutine ID5@util/log/file.go:456: Line number and source location[n1,s1]: Node and store tagssample log message: Log message
Viewing Logs
Slow Query Logging
Enable logging for slow queries:SQL_PERF channel:
Slow Query Log Format
Slow query logs include:- Query text
- Execution time
- Number of rows processed
- Resources used (CPU, memory, network)
- Execution plan
Audit Logging
Enable audit logging for security compliance:Structured Logging
JSON Format
Output logs in JSON format for log aggregation systems:Fluent Bit / Fluentd Integration
Configure CockroachDB to send logs to Fluent Bit:Deprecated Log Flags
Older log flags are deprecated in favor of--log:
Deprecated Flags and Equivalents
Deprecated Flags and Equivalents
| Deprecated Flag | Modern Equivalent |
|---|---|
--log-dir | --log='file-defaults: {dir: /path}' |
--log-file-verbosity | --log='file-defaults: {filter: LEVEL}' |
--log-file-max-size | --log='file-defaults: {max-file-size: SIZE}' |
--logtostderr | --log='sinks: {stderr: {channels: all}}' |
Checking Log Configuration
Verify your log configuration:Common Log Configurations
Production Configuration
Development Configuration
Container Configuration
Log Analysis
Common Log Patterns
Log Aggregation
Integrate with log aggregation systems:- ELK Stack: Use Filebeat to ship logs to Elasticsearch
- Splunk: Configure Splunk forwarder to collect log files
- CloudWatch Logs: Use CloudWatch agent for AWS deployments
- Datadog: Send logs via Datadog agent
Best Practices
Logging Recommendations
Logging Recommendations
- Use appropriate log levels: INFO for production, DEBUG for troubleshooting
- Separate sensitive logs: Isolate audit and security logs
- Monitor log volume: High verbosity can impact performance
- Rotate logs regularly: Prevent disk space exhaustion
- Centralize logs: Use log aggregation for multi-node clusters
- Retain audit logs: Comply with regulatory requirements
- Test log configuration: Use
debug check-log-configbefore deployment - Document log locations: Ensure team knows where to find logs
Troubleshooting
Logs Not Appearing
- Verify log directory exists and is writable
- Check
--logconfiguration syntax - Review stderr for configuration errors
- Ensure sufficient disk space
High Log Volume
- Reduce log level (INFO → WARNING)
- Disable verbose channels
- Adjust
max-file-sizeand retention - Filter out noisy log messages
Missing Log Entries
- Check log level filters
- Verify channel configuration
- Review log rotation settings
- Check for disk space issues
See Also
- Monitoring - Metrics and observability
- Metrics - Performance metrics
- Configuration - General configuration options