Table of Contents

Log

Description

Global static logging available anywhere without injection. Messages are queued and written on a background thread — main thread is never blocked. Supports file, stdout/stderr and custom writers.

Features

  • Global access: Log.Error(), Log.Warning(), Log.Information(), Log.Debug(), Log.Trace(), Log.Critical(), Log.Dump() — no injection needed
  • Auto-enrichment: optionally appends URL, query string, browser name, correlation ID and authenticated state to each message
  • Multiple formats: Text, JSON or HTML output
  • Log forwarding: forward framework logs to stdout/stderr, or forward stdout/stderr into your ILogWriter
  • File writer: built-in fallback file writer with file size limit
  • Flush on shutdown: queue is drained before app exits

Behavior

Log.Dump() bypasses the queue and rate limiter — written immediately and directly. Use for debugging only.

Log.Debug() and Log.Dump() skip URL, browser and stack trace enrichment for performance.

Log forwarding modes:

  • Default → your ILogWriter receives all log calls, stdout/stderr untouched
  • LogToStd → all log calls go to stdout/stderr with ANSI color support
  • StdToLog → stdout/stderr is forwarded into your ILogWriter

If no ILogWriter is registered, falls back to file writer at %HomeDrive%/Logs/Dump.log.

Correlation ID is auto-generated per request if not already present in HttpContext.Items.

Caveats

  • Log.Dump() should not be used in production — no rate limiting, no queuing, direct write
  • File writer has no log rotation
  • Rate limited: max 400 messages per 4ms interval, discards silently and logs one warning per overflow
Tip

Implement ILogWriter and register it as a singleton to send logs to Datadog, Application Insights or any other sink — the framework handles all enrichment and formatting before calling Write().

AppSettings

View all appsettings here