Skip to content

HttpTransportOptions

Define HttpTransport options.

Provide settings to configure HTTP endpoint, batching, retry, concurrency, and authentication for log delivery.

Levels extends Record<string, number> = DEFAULT_LEVELS

mapping from level names to numeric priorities.

optional auth: HttpAuth

Define authentication method for HTTP requests.

HttpAuthNone

optional batchSize: number

Number of log entries to batch per HTTP request.

100

optional categories: Set<string>

Set of categories to include. If provided, only logs whose meta.category matches one of these entries will be emitted.

TransportOptions.categories


optional concurrency: number

Maximum number of concurrent HTTP requests.

10

optional context: Record<string, unknown>

Additional context for each log specific to the transport. Context object is deep-merged to the log objects. (e.g fields required by sink.)

TransportOptions.context


optional encoding: BufferEncoding

Encoding for raw message writes (e.g., ‘utf8’, ‘utf16le’).

TransportOptions.encoding


optional filter: (log) => boolean

Predicate to filter individual logs. Return false to drop the log. Executed in the main thread.

Log<Levels>

boolean

TransportOptions.filter


optional flushInterval: number

Interval in milliseconds to flush pending batches.

5000

optional formatter: FormatterOptions<Levels>

Formatter configuration describing output shape, serialization, and content type.

TransportOptions.formatter


optional headers: Record<string, string>

Include custom headers in each request.

{ 'Content-Type': 'application/json' }


optional levels: LevelName<Levels>[]

Explicit set of level names to include. If provided, only logs whose level name appears in this array will be emitted.

TransportOptions.levels


optional logLevel: number

Minimum numeric severity to accept. Logs below this level are dropped.

TransportOptions.logLevel


optional method: "POST" | "PUT"

Specify HTTP method for sending logs.

'POST'

optional name: string

Human-readable name for this transport. Defaults to the transport class name.

TransportOptions.name


optional onError: (err) => void

Handler invoked on any transport-level error. Receives a TransportError with details about the failure context.

TransportError<Levels>

void

TransportOptions.onError


optional retry: RetryOption

Configure retry behavior for failed HTTP calls.


optional runAsWorker: boolean

Whether to offload log processing to a worker thread.

TransportOptions.runAsWorker


optional transformer: (log) => null | Log<Levels>

Function to transform or drop logs. Return a new modified Log to proceed, or null to skip. Do not modify original log object to prevent side-effects.

Log<Levels>

null | Log<Levels>

TransportOptions.transformer


url: string

Target URL where logs will be delivered.


optional worker: object

Worker-specific settings when runAsWorker is true:

  • closeTimeout: ms to wait for worker to exit before aborting.
  • readyTimeout: ms to wait for worker to signal ready.
  • url: override URL of worker script.
  • custom: factory function to create a Worker instance.

optional closeTimeout: number

Timeout (ms) for the worker.close handshake. Default: 60000.

optional custom: () => Worker

Custom factory for instantiating the worker.

Worker

optional readyTimeout: number

Timeout (ms) for the worker ready handshake. Default: 30000.

optional url: URL

Override the script URL for the worker.

TransportOptions.worker