18 — Logging Standards

Status: Ratified Version: 1.0.0 Applies to: All components; JSON logging; metrics; tracing; telemetry; audit


1. Logging Model

HunterX logs are structured, correlatable, and machine-parseable. The default transport is JSON-lines to stdout plus optional file sinks. Human readability comes from renderers, not from log prose.

Three correlated signals share the trace_id/correlation_id:

  1. Logs (events)
  2. Metrics (aggregate counters/histograms/gauges)
  3. Traces (span trees)

2. Log Line Contract

Every log line is a JSON object with a canonical base schema:

{
  "ts": "2026-08-05T12:34:56.789Z",
  "level": "info",
  "logger": "hunterx.engines.workflow",
  "correlation_id": "01J...",
  "span_id": "abc123",
  "trace_id": "def456",
  "actor": "operator@example.com",
  "module": "workflow",
  "message": "workflow.step_completed",
  "context": {"step_id": "port-scan", "duration_ms": 1234},
  "event_type": "workflow.step_completed",
  "schema_version": "1.0"
}

Rules:


3. Event Categories

Category Prefix Examples
System system.* system.startup, system.shutdown
Mission mission.* mission.started, mission.phase_changed
Workflow workflow.* workflow.step_completed, workflow.resumed
Task task.* task.queued, task.retrying
Tool tool.* tool.completed, tool.failed, tool.rate_limited
Finding finding.* finding.created, finding.deduped
Plan plan.* plan.generated, plan.replanned
AI ai.* ai.call_started, ai.output_rejected
Plugin plugin.* plugin.loaded, plugin.ban
Auth auth.* auth.login_success, auth.login_failed
Audit audit.* audit.action (append-only)
Degradation degradation.* degradation.activated

4. Metrics Contract

Metric Type Where
hx_workflow_steps_total{status} counter engine
hx_workflow_step_duration_seconds histogram engine
hx_tool_runs_total{tool,outcome} counter executor
hx_tool_duration_seconds histogram executor
hx_ai_calls_total{capability,outcome} counter AI engine
hx_ai_latency_seconds histogram AI engine
hx_findings_created_total{category} counter store
hx_ingest_events_total counter normalizer
hx_queue_depth gauge queue
hx_worker_pool_utilization gauge workers
hx_db_query_duration_seconds histogram store
hx_cache_hit_ratio gauge cache
hx_degradation_activations_total counter cross-cutting
hx_http_requests_total{route,status} counter API
hx_http_request_duration_seconds histogram API

5. Tracing


6. Audit Logging


7. Performance Logging


8. Sensitive Data Handling


9. Leveling & Volume Control


10. Configuration

logging:
  level: info
  format: json            # json|text(dev)
  sinks:
    - stdout
    - file: /var/log/hunterx/hunterx.log (rotation: 50MB x 10)
  tracing:
    enabled: true
    exporter: otlp
    sample_rate: 1.0
  metrics:
    exporter: prometheus
  audit:
    sink: append-only-file|postgres|worm

11. References