Visitar URL original
DateLayoutRenderer default Format should be culture invariant · Issue #6232 · NLog/NLog · GitHub
Skip to content

DateLayoutRenderer default Format should be culture invariant #6232

Open

Description

@snakefoot

Little weird that DateLayoutRenderer has the default Format:

  • yyyy/MM/dd HH:mm:ss.fff

Why not follow the default-format found every where else in NLog:

  • yyyy-MM-dd HH:mm:ss.ffff

Interesting that ${date} "originally" was born with default Format = G, that would follow the local culture. Then later hard-coded to one culture with explicit Format-string (with ffff). Think that Logging library should stay culture invariant unless requested otherwise.

Also $[processtime} should match the following format (Instead of fff):

  • HH:mm:ss.ffff

Activity

  1. added this to the 7.0 milestone on Jul 11, 2026
  2. changed the title [-]DateLayoutRenderer should change default Format[/-] [+]DateLayoutRenderer should have culture invariant default Format[/+] on Jul 11, 2026
  3. changed the title [-]DateLayoutRenderer should have culture invariant default Format[/-] [+]DateLayoutRenderer Format should be culture invariant[/+] on Jul 11, 2026
  4. changed the title [-]DateLayoutRenderer Format should be culture invariant[/-] [+]DateLayoutRenderer default Format should be culture invariant[/+] on Jul 11, 2026
  5. HarnageaGabriel commented on Aug 18, 2026

    @HarnageaGabriel

    Hi @snakefoot, looking into this one.

    Investigating DateLayoutRenderer on dev, I see the Culture property already defaults to CultureInfo.InvariantCulture (set in DateLayoutRenderer.cs via #5740, merged 2025-03-23), and GetFormatProvider always prefers that non-null layout-level culture over logEvent.FormatProvider/DefaultCultureInfo. So with today's dev code, the default ${date} output is already culture-invariant in the sense that it won't change with the thread/system culture — the / and : literals in the format string resolve to invariant separators regardless of environment.

    So the concrete remaining gap looks like it's the default Format string itself: yyyy/MM/dd HH:mm:ss.fff vs. the convention used elsewhere in NLog (${longdate}, InternalLogger) of yyyy-MM-dd HH:mm:ss.ffff. Changing that default text is a visible output change for anyone using ${date} without an explicit Format, which is presumably why this is tagged breaking change/breaking behavior change.

    Before I write the fix, which direction do you want:

    (a) Straight default change — flip the default Format to yyyy-MM-dd HH:mm:ss.ffff to match the rest of NLog. Breaking, would need a major version bump.
    (b) Opt-in — keep today's default Format string as-is, and add an opt-in way to get the invariant/ffff convention (e.g. a configurable flag or documented alternate format) without touching existing behavior for current users.
    (c) Something else you have in mind — including whether ProcessTimeLayoutRenderer's fff→ffff mention should be split into its own issue.

    If I don't hear back in a bit I'll go with (b) as the safer non-breaking default, and note (a) as an easy follow-up if you'd rather take the breaking route.

  6. snakefoot commented on Aug 18, 2026

    @snakefoot
    ContributorAuthor

    The milestone is for NLog v7 (milestone). I just have a bad memory, so I use Github-issue to remember my observations.

    There is no bug, it is just a funny default value, so people who needs different Format can just assign a different value (already working).

    See also #6235 for other NLog v7 related ideas that I'm thinking about. There is no NLog v7 roadmap or deadline, so mostly for the todo-list.

  7. added a commit that references this issue on Sep 18, 2026
    2165b71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions