Monitoring
This guide covers logging configuration for Codumentor deployments.
Logging Configuration
Codumentor's logging is configured through the logging section of codumentor.yaml.
Basic Configuration
logging:
level: INFO
file: ./logs/codumentor.log
logger_levels:
codumentor.agent: DEBUG
codumentor.tools: WARNING
codumentor.api: INFO
codumentor.ingest: DEBUG
| Setting | Default | Description |
|---|---|---|
level | INFO | Base log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL. |
file | ./logs/codumentor.log | Path to the log file. |
logger_levels | {} | Per-logger level overrides. Keys are dotted logger names (e.g., codumentor.agent). |
The logger_levels setting lets you increase verbosity for specific components without flooding the log with debug output from the entire application. For example, setting codumentor.agent: DEBUG while keeping the base level at INFO gives detailed agent traces without noisy tool output.
File permissions. The log file, the JSON log and their rotated copies are created with mode 0640: readable by the service account and its group, not by other local accounts. A log shipper (Filebeat, the Datadog agent, Splunk forwarder) that reads the files directly must run as the service user or be a member of the service's group (for example usermod -aG codumentor dd-agent). The payload trace file (*.trace.log) holds full prompts and is 0600, owner only. Files created by an older version keep their mode until they are reopened by the server, which tightens them.
Structured JSON Logging
For production deployments, enable structured JSON logging to integrate with log aggregation systems like ELK, Splunk, or Datadog:
logging:
level: INFO
file: ./logs/codumentor.log
json_logging: true
json_log_file: ./logs/codumentor.json.log
json_include_context: true
json_include_stack_info: false
json_include_process_info: false
| Setting | Default | Description |
|---|---|---|
json_logging | false | Enable structured JSON logging. |
json_log_file | null | Path to the JSON log file. If not set, uses the standard log file path with a .json extension. |
json_include_context | true | Include contextual metadata (session IDs, request data) in log entries. |
json_include_stack_info | false | Include stack traces. Useful for debugging, noisy in production. |
json_include_process_info | false | Include process and thread identifiers. |
json_date_format | ISO 8601 with ms | Custom date format string. Default: %Y-%m-%dT%H:%M:%S.%f. |
JSON Log Format
Each log entry is a single JSON line:
{
"timestamp": "2026-02-16T10:30:00.123",
"level": "INFO",
"logger": "codumentor.api",
"message": "Request completed",
"module": "api",
"function": "handle_request",
"line": 87,
"context": {
"session_id": "sess_abc123",
"user_id": "jdoe",
"request_id": "req_xyz789"
}
}
The context field contains metadata about the current operation, including session identifiers, user information, and request-specific data. This is valuable for correlating log entries across a single user session or request.
Processing Logs with jq
JSON logs can be queried and filtered with jq:
# Show only ERROR-level entries
jq 'select(.level == "ERROR")' logs/codumentor.json.log
# Filter by logger name
jq 'select(.logger == "codumentor.agent")' logs/codumentor.json.log
# Extract timestamps and messages
jq '{timestamp: .timestamp, message: .message}' logs/codumentor.json.log
# Find entries related to a specific session
jq 'select(.context.session_id == "sess_abc123")' logs/codumentor.json.log
# Count entries by log level
jq -s 'group_by(.level) | map({level: .[0].level, count: length})' logs/codumentor.json.log
# Search for a keyword in messages
jq 'select(.message | contains("ingestion complete"))' logs/codumentor.json.log
Per-Logger Levels
Customize log verbosity per component to focus on what matters:
logging:
level: WARNING
logger_levels:
codumentor.agent: DEBUG # Detailed agent reasoning traces
codumentor.tools: WARNING # Only tool warnings and errors
codumentor.api: INFO # API request/response logging
codumentor.ingest: INFO # Ingestion progress
codumentor.plugins: DEBUG # Plugin lifecycle debugging
Common logger names:
| Logger | Content |
|---|---|
codumentor.agent | Agent turns, tool calls, reasoning |
codumentor.tools | Tool execution, shell commands, file operations |
codumentor.api | HTTP requests, SSE connections, authentication |
codumentor.ingest | Repository cloning, chunking, embedding |
codumentor.plugins | Plugin loading, hook execution, plugin errors |
Reading the Text Log
A text-log record looks like this; session-scoped records carry a context prefix after >:
2026-07-06 10:40:19,067 - api - INFO - Shutting down Codumentor API server...
2026-07-07 08:23:39,735 > session_id=c_a27b741af82c4ae... tool=read_file - telemetry - INFO - Tool read_file ms=10.1
- Lines that do not start with a timestamp continue the previous record (tracebacks, multi-line payloads, subprocess stderr). Line-based grep misses them; use
grep -Afor context. - Anchor searches to the record structure. At
DEBUG, records embed prompts, tool results and file contents, so a baregrep ERRORmatches payload text. Usegrep ' - ERROR - ', and pipe throughcut -c1-300— single records can be tens of KB. - The session id in the prefix is truncated with a literal
...; match it as a prefix (grep -F 'session_id=c_a27b741'). Context field order is not fixed. - Timestamps are server local time without an offset, while rotation (when
rotation_enabled: true) happens at midnight UTC by default (rotation_utc), so a dated file can contain a few hours of the neighbouring local day. - Never open a running instance's SQLite databases directly, not even read-only. They use WAL mode, and a read-only open still creates the
-wal/-shmsidecar files — owned by your user. The service then cannot write them and fails withattempt to write a readonly database. Copy the file and query the copy. If it already happened, give the sidecars back to the service user (chown/chgrp+chmod); do not delete the sidecars of a live database.
Best Practices
- Use JSON logging in production. Structured logs enable filtering, searching, and alerting through standard tools.
- Set appropriate log levels per component. Use
DEBUGonly for the components you are actively investigating. Leave everything else atINFOorWARNING. - Configure log rotation. Use logrotate or a similar tool to prevent log files from filling the disk. Example logrotate configuration:
````
/opt/codumentor/logs/*.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
copytruncate
}
- Monitor for errors. Set up alerts on
ERRORandCRITICALentries. With JSON logging, this is straightforward to integrate with any alerting system. - Protect log files. Logs may contain conversation content, session identifiers, and user information. Restrict filesystem permissions to the service user.
See Also
- Deployment -- Production deployment checklist including log rotation
- Configuration -- Full configuration reference including the
loggingsection