Skip to content

Modern Log WithField

Paul Squires edited this page Oct 26, 2026 · 6 revisions

Home › Logging › Logging › WithField

WithField

Returns a child logger that adds one field to every record it makes.

Syntax

WithField( k, v as LogValue ) as LoggerType

Examples

#import "std/logs"
using logs

dim con as ConsoleSink
dim lg as Logger
lg.AddSink( @con )

'' A child carrying one field on EVERY record it makes -- per-request or
'' per-connection context attached once instead of at each call site
dim req as Logger = lg.WithField( "reqid", LogValue( "abc123" ) )

req.Info( "received" )
req.Info( "answered" )       '' both lines carry reqid=abc123

Library: Logging
Category: Logging
Documented under: Members

Clone this wiki locally