Log Storage

Snap CD captures and stores logs from Job execution, providing visibility into Terraform/OpenTofu operations.

How Logs Work

  1. Runners execute Jobs and generate logs via Serilog
  2. Logs are batched and sent to the Server via SignalR in real-time
  3. The Server stores logs as JSON in the database, attached to the ModuleJob record
  4. Logs are available in the Dashboard and via the API

Log Entry Structure

Each log entry contains:

FieldDescription
TimestampWhen the log entry was created
LevelSeverity: Verbose, Debug, Information, Warning, Error, Fatal
MessageThe log message content
TaskNameThe Job step (e.g., Init, Plan, Apply, Output)
ModuleIdThe Module that generated the log
StackName / NamespaceName / ModuleNameContext for the log entry

Real-time Streaming

Logs are streamed to the Dashboard in real-time as Jobs execute. The Runner batches logs (default: every 5 seconds or 50 entries) and sends them via a persistent SignalR connection.

If the connection is temporarily lost, logs are buffered locally (up to 10,000 entries) and flushed when the connection is restored.

Runner Configuration

Configure log batching on the Runner in appsettings.json:

{
  "Logging": {
    "SystemDefaultLogLevel": "Error",
    "SnapCdDefaultLogLevel": "Information",
    "BatchSizeLimit": 50,
    "PeriodSeconds": 5
  }
}
SettingDefaultDescription
SystemDefaultLogLevelErrorLog level for system/framework logs
SnapCdDefaultLogLevelInformationLog level for Snap CD application logs
BatchSizeLimit50Maximum entries per batch
PeriodSeconds5How often to send batches

API Access

Logs can be retrieved via the API:

  • GET /api/{organizationId}/logs/{jobId} - Returns structured log entries
  • GET /api/{organizationId}/logs/string/{jobId} - Returns concatenated log text

Storage

Logs are stored in the database as part of the ModuleJob entity. They persist for the lifetime of the Job record.

Last updated on