feat: add UTC timestamps to all console log entries#3709
Open
JerryNixon with Copilot wants to merge 3 commits into
Open
feat: add UTC timestamps to all console log entries#3709JerryNixon with Copilot wants to merge 3 commits into
JerryNixon with Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
[WIP] Add timestamp to logs for better tracking
feat: add UTC timestamps to all console log entries
Jul 8, 2026
JerryNixon
approved these changes
Jul 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make console logs easier to correlate by prepending an ISO 8601 UTC timestamp (millisecond precision) to console output emitted by both the Service host and the CLI custom logger.
Changes:
- Updated Service logging to use the console “simple” formatter with UTC timestamp settings (including MCP stdio stderr routing for the startup logger factory).
- Updated the CLI custom console logger to prepend a UTC timestamp before the abbreviated log level label.
- Adjusted CLI unit tests for the new timestamp-prefixed output (but the updated assertion is now too permissive).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Service/Program.cs | Switches console logging to include UTC timestamps; MCP stdio path continues to keep stdout clean. |
| src/Cli/CustomLoggerProvider.cs | Prepends UTC timestamps to CLI log prefixes for both standard and MCP stdio modes. |
| src/Cli.Tests/CustomLoggerTests.cs | Updates assertions to account for timestamps in log output. |
| // Apply colors so the abbreviation matches the visual style of engine logs. | ||
| // try/finally guarantees the original colors are restored even if Write throws, | ||
| // otherwise the console would be left tinted (e.g. red on error) for subsequent output. | ||
| string mcpTimestamp = DateTime.UtcNow.ToString(UtcTimestampFormat); |
| } | ||
|
|
||
| TextWriter writer = logLevel >= LogLevel.Error ? Console.Error : Console.Out; | ||
| string timestamp = DateTime.UtcNow.ToString(UtcTimestampFormat); |
Comment on lines
+80
to
+81
| Assert.IsTrue(actual.Contains(expectedPrefix), | ||
| $"Expected output to contain '{expectedPrefix}' but got: '{actual}'"); |
Comment on lines
+198
to
+202
| logging.AddSimpleConsole(options => | ||
| { | ||
| options.TimestampFormat = "yyyy-MM-dd'T'HH:mm:ss.fff'Z' "; | ||
| options.UseUtcTimestamp = true; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
Console log output lacks timestamps, making it difficult to correlate events or determine when entries occurred — especially under high request volume.
What is this change?
Prepends an ISO 8601 UTC timestamp with millisecond precision to every console log entry:
src/Service/Program.cs— ReplacesAddConsole()withAddSimpleConsole(TimestampFormat, UseUtcTimestamp)in bothGetLoggerFactoryForLogLevel(startup logger) andCreateHostBuilder.ConfigureLogging(web host logger). MCP stdio path additionally usesServices.Configure<ConsoleLoggerOptions>for stderr routing, keeping a single registered provider.src/Cli/CustomLoggerProvider.cs— PrependsDateTime.UtcNow.ToString(UtcTimestampFormat)before the abbreviated level label in the CLI's custom console logger (both standard and MCP stdio paths). Timestamp format extracted to a named constant.src/Cli.Tests/CustomLoggerTests.cs— UpdatesLogOutput_UsesAbbreviatedLogLevelLabelsassertion fromStartsWithtoContainssince the timestamp now precedes the level label.How was this tested?
Sample Request(s)
No REST/GraphQL/CLI request changes — output-only behavioral change visible when running
dab start.