Skip to main content

Fixed: Timestamp Stuck to the Log Level in ASP.NET Core Console Logs

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

My plain-text logs came out as 2026-11-06T08:00:35.102Zinfo: Program[0], with the timestamp stuck to the log level. A TimestampFormat I'd set for JSON logs had carried over to Development. Here's why, and three ways to fix it.

What I Was Doing​

I wanted JSON logs in production, set in configuration, with plain text on my own machine. So appsettings.json turns on the JSON formatter, on a .NET 10 ASP.NET Core app:

appsettings.json (excerpt)
"Logging": {
"Console": {
"FormatterName": "json",
"FormatterOptions": {
"UseUtcTimestamp": true,
"TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffZ"
}
}
}

And appsettings.Development.json switches back:

appsettings.Development.json
{
"Logging": {
"Console": {
"FormatterName": "simple"
}
}
}

What I Expected​

Plain logs in Development, as they always look:

Expected
info: Program[0]
Looking up order 42

What I Got​

API log
2026-11-06T08:00:35.102Zinfo: Program[0]
Looking up order 42

The API log in Development showing 2026-11-06T08:00:35.102Zinfo: Program[0], with the timestamp stuck to the log level.

What I Checked​

Where the setting comes from. FormatterOptions isn't tied to one formatter. It's one section, under Logging:Console, and appsettings.Development.json only changed FormatterName. So Development still has the format from appsettings.json.

How the documentation writes it. Every example on Microsoft's console log formatting page has a space at the end: "TimestampFormat": "HH:mm:ss ". The format is written just as it is, right before the level, so the space has to be part of it.

Whether a space in the shared format would do. It fixes the plain logs, and it puts a stray space in each JSON Timestamp:

API log, with HH:mm:ss and a space, as JSON (the start of a line)
{"Timestamp":"08:05:42 ","EventId":0,"LogLevel":"Information","Category":"Program","Message":"Looking up order 42","Stat

Why It Happens​

The plain formatter writes the timestamp and then the level, with nothing between them. In JSON, the timestamp has a field of its own, so a format with no space at the end is the right one there. The two formatters share one setting, and what suits one doesn't suit the other.

The Fix​

Any of these works. I'd use the third.

1. Clear the format in Development, with null in appsettings.Development.json:

appsettings.Development.json
{
"Logging": {
"Console": {
"FormatterName": "simple",
"FormatterOptions": {
"TimestampFormat": null
}
}
}
}

2. Give Development its own format, with a space at the end:

appsettings.Development.json (excerpt)
"FormatterOptions": {
"TimestampFormat": "HH:mm:ss "
}

3. Set JSON logs in code, outside Development, so that Development never has these options at all. How to Write JSON Logs in ASP.NET Core shows this.

After the Fix​

With the first:

API log
info: Program[0]
Looking up order 42

With the second:

API log
08:00:44 info: Program[0]
Looking up order 42

The API log in Development showing info: Program[0] with no timestamp after clearing the format, and 08:00:44 info: Program[0] with its own format.

And production's JSON is as it was:

API log, as Production
{"Timestamp":"2026-11-06T08:00:48.785Z","EventId":0,"LogLevel":"Information","Category":"Program","Message":"Looking up order 42","State":{"OrderId":42,"{OriginalFormat}":"Looking up order {OrderId}"}

Common Mistakes​

MistakeWhat happensDo this instead
Adding a space to the shared formatA stray space in each JSON TimestampChange only Development's
Removing the options from appsettings.Development.json onlySettings merge, so the ones in appsettings.json still applyOverride them

Troubleshooting​

SymptomLikely causeFix
No timestamp in plain logsThat's the defaultSet a format, with a space at the end
No Timestamp field in JSONThat's the default tooSet TimestampFormat
The change does nothingThe environment isn't DevelopmentCheck it

Conclusion​

The plain formatter writes TimestampFormat right before the level, so it needs a space at the end, and JSON doesn't. Keep them apart: clear it or replace it for Development, or set JSON logs in code.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.