ObjectStackObjectStack

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

PropertyTypeRequiredDescription
streamEnum<'stdout' | 'stderr'>
colorsboolean
prettyPrintboolean

ExtendedLogLevel

Extended log severity level

Allowed Values

  • trace
  • debug
  • info
  • warn
  • error
  • fatal

ExternalServiceDestinationConfig

External service destination configuration

Properties

PropertyTypeRequiredDescription
endpointstringoptional
regionstringoptional
credentials{ accessKeyId?: string; secretAccessKey?: string; apiKey?: string; environmentId?: string }optional
logGroupstringoptional
logStreamstringoptional
indexstringoptional
configRecord<string, any>optional

FileDestinationConfig

File destination configuration

Properties

PropertyTypeRequiredDescription
pathstringLog file path
rotation{ maxSize: string; maxFiles: integer; compress: boolean; interval?: Enum<'hourly' | 'daily' | 'weekly' | 'monthly'> }optional
encodingstring
appendboolean

HttpDestinationConfig

HTTP destination configuration

Properties

PropertyTypeRequiredDescription
urlstringHTTP endpoint URL
methodEnum<'POST' | 'PUT'>
headersRecord<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
timeoutinteger

LogDestination

Log destination configuration

Properties

PropertyTypeRequiredDescription
namestringDestination name (snake_case)
typeEnum<'console' | 'file' | 'syslog' | 'elasticsearch' | 'cloudwatch' | 'stackdriver' | 'azure_monitor' | 'datadog' | 'splunk' | 'loki' | 'http' | 'kafka' | 'redis' | 'custom'>Destination type
levelEnum<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>Extended log severity level
enabledboolean
console{ stream: Enum<'stdout' | 'stderr'>; colors: boolean; prettyPrint: boolean }optionalConsole destination configuration
file{ path: string; rotation?: object; encoding: string; append: boolean }optionalFile destination configuration
http{ url: string; method: Enum<'POST' | 'PUT'>; headers?: Record<string, string>; auth?: object; … }optionalHTTP destination configuration
externalService{ endpoint?: string; region?: string; credentials?: object; logGroup?: string; … }optionalExternal service destination configuration
formatEnum<'json' | 'text' | 'pretty'>
filterIdstringoptionalFilter function identifier

LogDestinationType

Log destination type

Allowed Values

  • console
  • file
  • syslog
  • elasticsearch
  • cloudwatch
  • stackdriver
  • azure_monitor
  • datadog
  • splunk
  • loki
  • http
  • kafka
  • redis
  • custom

LogEnrichmentConfig

Log enrichment configuration

Properties

PropertyTypeRequiredDescription
staticFieldsRecord<string, any>optionalStatic fields added to every log
dynamicEnrichersstring[]optionalDynamic enricher function IDs
addHostnameboolean
addProcessIdboolean
addEnvironmentboolean
addTimestampFormats{ unix: boolean; iso: boolean }optional
addCallerboolean
addCorrelationIdsboolean

LogEntry

Properties

PropertyTypeRequiredDescription
timestampstringISO 8601 timestamp
levelEnum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'>Log severity level
messagestringLog message
contextRecord<string, any>optionalStructured context data
errorRecord<string, any>optionalError object if present
traceIdstringoptionalDistributed trace ID
spanIdstringoptionalSpan ID
servicestringoptionalService name
componentstringoptionalComponent name (e.g. plugin id)

LogFormat

Log output format

Allowed Values

  • json
  • text
  • pretty

LogLevel

Log severity level

Allowed Values

  • debug
  • info
  • warn
  • error
  • fatal
  • silent

LoggerConfig

Properties

PropertyTypeRequiredDescription
namestringoptionalLogger name identifier
levelEnum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'>Log severity level
formatEnum<'json' | 'text' | 'pretty'>Log output format
redactstring[]Keys to redact from log context
sourceLocationbooleanInclude file and line number
filestringoptionalPath to log file
rotation{ maxSize: string; maxFiles: number }optional

LoggingConfig

Logging configuration

Properties

PropertyTypeRequiredDescription
namestringConfiguration name (snake_case, max 64 chars)
labelstringDisplay label
enabledboolean
levelEnum<'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[]; … }optionalDefault logger configuration
loggersRecord<string, { name?: string; level: Enum<'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent'>; format: Enum<'json' | 'text' | 'pretty'>; redact: string[]; … }>optionalNamed 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; … }optionalLog enrichment configuration
redactstring[]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

PropertyTypeRequiredDescription
timestampstringISO 8601 timestamp
levelEnum<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>Log severity level
messagestringLog message
contextRecord<string, any>optionalStructured context
error{ name?: string; message?: string; stack?: string; code?: string; … }optionalError details
trace{ traceId: string; spanId: string; parentSpanId?: string; traceFlags?: integer }optionalDistributed tracing context
source{ service?: string; component?: string; file?: string; line?: integer; … }optionalSource information
host{ hostname?: string; pid?: integer; ip?: string }optionalHost information
environmentstringoptionalEnvironment (e.g., production, staging)
user{ id?: string; username?: string; email?: string }optionalUser context
request{ id?: string; method?: string; path?: string; userAgent?: string; … }optionalRequest context
labelsRecord<string, string>optionalCustom labels
metadataRecord<string, any>optionalAdditional metadata

On this page