Logging
Logging protocol schemas
Logging Protocol - Comprehensive Observability Logging
Unified logging protocol that combines:
- Basic kernel logging (LoggerConfig)
- Enterprise-grade features (LoggingConfig)
- Multiple log destinations (file, console, external services)
- Structured logging with enrichment
- Log aggregation and forwarding
- Integration with external log management systems
Source: packages/spec/src/system/logging.zod.ts
TypeScript Usage
import { ConsoleDestinationConfigSchema, ExtendedLogLevel, ExternalServiceDestinationConfigSchema, FileDestinationConfigSchema, HttpDestinationConfigSchema, LogDestinationSchema, LogDestinationType, LogEnrichmentConfigSchema, LogEntrySchema, LogFormat, LogLevel, LoggerConfigSchema, LoggingConfigSchema, StructuredLogEntrySchema } from '@objectstack/spec/system';
import type { ConsoleDestinationConfig, ExtendedLogLevel, ExternalServiceDestinationConfig, FileDestinationConfig, HttpDestinationConfig, LogDestination, LogDestinationType, LogEnrichmentConfig, LogEntry, LogFormat, LogLevel, LoggerConfig, LoggingConfig, StructuredLogEntry } from '@objectstack/spec/system';
// Validate data
const result = ConsoleDestinationConfigSchema.parse(data);ConsoleDestinationConfig
Console destination configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| stream | Enum<'stdout' | 'stderr'> | ✅ | |
| colors | boolean | ✅ | |
| prettyPrint | boolean | ✅ |
ExtendedLogLevel
Extended log severity level
Allowed Values
tracedebuginfowarnerrorfatal
ExternalServiceDestinationConfig
External service destination configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| endpoint | string | optional | |
| region | string | optional | |
| credentials | { accessKeyId?: string; secretAccessKey?: string; apiKey?: string; environmentId?: string } | optional | |
| logGroup | string | optional | |
| logStream | string | optional | |
| index | string | optional | |
| config | Record<string, any> | optional |
FileDestinationConfig
File destination configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| path | string | ✅ | Log file path |
| rotation | { maxSize: string; maxFiles: integer; compress: boolean; interval?: Enum<'hourly' | 'daily' | 'weekly' | 'monthly'> } | optional | |
| encoding | string | ✅ | |
| append | boolean | ✅ |
HttpDestinationConfig
HTTP destination configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | ✅ | HTTP endpoint URL |
| method | Enum<'POST' | 'PUT'> | ✅ | |
| headers | Record<string, string> | optional | |
| auth | { type: Enum<'basic' | 'bearer' | 'api_key'>; username?: string; password?: string; token?: string; … } | optional | |
| batch | { maxSize: integer; flushInterval: integer } | optional | |
| retry | { maxAttempts: integer; initialDelay: integer; backoffMultiplier: number } | optional | |
| timeout | integer | ✅ |
LogDestination
Log destination configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Destination name (snake_case) |
| type | Enum<'console' | 'file' | 'syslog' | 'elasticsearch' | 'cloudwatch' | 'stackdriver' | 'azure_monitor' | 'datadog' | 'splunk' | 'loki' | 'http' | 'kafka' | 'redis' | 'custom'> | ✅ | Destination type |
| level | Enum<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'> | ✅ | Extended log severity level |
| enabled | boolean | ✅ | |
| console | { stream: Enum<'stdout' | 'stderr'>; colors: boolean; prettyPrint: boolean } | optional | Console destination configuration |
| file | { path: string; rotation?: object; encoding: string; append: boolean } | optional | File destination configuration |
| http | { url: string; method: Enum<'POST' | 'PUT'>; headers?: Record<string, string>; auth?: object; … } | optional | HTTP destination configuration |
| externalService | { endpoint?: string; region?: string; credentials?: object; logGroup?: string; … } | optional | External service destination configuration |
| format | Enum<'json' | 'text' | 'pretty'> | ✅ | |
| filterId | string | optional | Filter function identifier |
LogDestinationType
Log destination type
Allowed Values
consolefilesyslogelasticsearchcloudwatchstackdriverazure_monitordatadogsplunklokihttpkafkarediscustom
LogEnrichmentConfig
Log enrichment configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| staticFields | Record<string, any> | optional | Static fields added to every log |
| dynamicEnrichers | string[] | optional | Dynamic enricher function IDs |
| addHostname | boolean | ✅ | |
| addProcessId | boolean | ✅ | |
| addEnvironment | boolean | ✅ | |
| addTimestampFormats | { unix: boolean; iso: boolean } | optional | |
| addCaller | boolean | ✅ | |
| addCorrelationIds | boolean | ✅ |
LogEntry
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| timestamp | string | ✅ | ISO 8601 timestamp |
| level | Enum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'> | ✅ | Log severity level |
| message | string | ✅ | Log message |
| context | Record<string, any> | optional | Structured context data |
| error | Record<string, any> | optional | Error object if present |
| traceId | string | optional | Distributed trace ID |
| spanId | string | optional | Span ID |
| service | string | optional | Service name |
| component | string | optional | Component name (e.g. plugin id) |
LogFormat
Log output format
Allowed Values
jsontextpretty
LogLevel
Log severity level
Allowed Values
debuginfowarnerrorfatalsilent
LoggerConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | optional | Logger name identifier |
| level | Enum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'> | ✅ | Log severity level |
| format | Enum<'json' | 'text' | 'pretty'> | ✅ | Log output format |
| redact | string[] | ✅ | Keys to redact from log context |
| sourceLocation | boolean | ✅ | Include file and line number |
| file | string | optional | Path to log file |
| rotation | { maxSize: string; maxFiles: number } | optional |
LoggingConfig
Logging configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Configuration name (snake_case, max 64 chars) |
| label | string | ✅ | Display label |
| enabled | boolean | ✅ | |
| level | Enum<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'> | ✅ | Extended log severity level |
| default | { name?: string; level: Enum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'>; format: Enum<'json' | 'text' | 'pretty'>; redact: string[]; … } | optional | Default logger configuration |
| loggers | Record<string, { name?: string; level: Enum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'>; format: Enum<'json' | 'text' | 'pretty'>; redact: string[]; … }> | optional | Named logger configurations |
| destinations | { name: string; type: Enum<'console' | 'file' | 'syslog' | 'elasticsearch' | 'cloudwatch' | 'stackdriver' | … +8 more>; level: Enum<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>; enabled: boolean; … }[] | ✅ | Log destinations |
| enrichment | { staticFields?: Record<string, any>; dynamicEnrichers?: string[]; addHostname: boolean; addProcessId: boolean; … } | optional | Log enrichment configuration |
| redact | string[] | ✅ | Fields to redact |
| sampling | { enabled: boolean; rate: number; rateByLevel?: Record<string, number> } | optional | |
| buffer | { enabled: boolean; size: integer; flushInterval: integer; flushOnShutdown: boolean } | optional | |
| performance | { async: boolean; workers: integer } | optional |
StructuredLogEntry
Structured log entry
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| timestamp | string | ✅ | ISO 8601 timestamp |
| level | Enum<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'> | ✅ | Log severity level |
| message | string | ✅ | Log message |
| context | Record<string, any> | optional | Structured context |
| error | { name?: string; message?: string; stack?: string; code?: string; … } | optional | Error details |
| trace | { traceId: string; spanId: string; parentSpanId?: string; traceFlags?: integer } | optional | Distributed tracing context |
| source | { service?: string; component?: string; file?: string; line?: integer; … } | optional | Source information |
| host | { hostname?: string; pid?: integer; ip?: string } | optional | Host information |
| environment | string | optional | Environment (e.g., production, staging) |
| user | { id?: string; username?: string; email?: string } | optional | User context |
| request | { id?: string; method?: string; path?: string; userAgent?: string; … } | optional | Request context |
| labels | Record<string, string> | optional | Custom labels |
| metadata | Record<string, any> | optional | Additional metadata |