Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Date layout renderer

Rolf Kristensen edited this page Oct 19, 2024 · 21 revisions

Current date and time.

Platforms Supported: All

Alternative ${longdate} or ${shortdate} can be used for high performance timestamp-logging.

Configuration Syntax

${date:universalTime=Boolean:format=String:culture=Culture}

Parameters

Rendering Options

  • universalTime - Indicates whether to output UTC time instead of local time.Boolean Default: False

  • format - Date format. Can be any argument accepted by DateTime.ToString(format).

    Note that colons need to escaped with a backslash:
    Example: ${date:format=yyyy-MM-dd HH\:mm\:ss.fff} -> DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") -> "2000-01-01 00:00:00.000"

    Note that backslashes, that shall be passed through, also need to be escaped:
    Example: ${date:format=\\Yyyyy\\MMM\\Ddd} -> DateTime.Now.ToString(@"\Yyyyy\MMM\Ddd") -> Y2000M01D01"

  • culture - Culture used for rendering. Default: InvariantCulture

Time Source Precision

NLog uses local-time by default, but because conversion from machine-time to local-time has an overhead, then NLog uses cached time-source FastLocal with 15ms time-precision that follows Environment.TickCount. For high time-precision and still fast performance, then consider using Time-source AccurateUtc (Time-precision of 1ms)

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.