microsoft / microsoft/aspire

`LogLine` should provide Timestamp as a seperate field, rather than fudge it into the log content

Open
#11,795 0 comments 0 reactions 0 assignees View on GitHub
area-app-model breaking-change
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

It would be useful if the LogLine provided the log's timestamp as a dedicated field, rather than mangling it into

- If the app already included the timestamp in it's logs, aspire appending another timestamp leads you to duplicate timestamps.
- If you want to do anything with the timestamp (e.g. mark the time in another system, change from an absolute time to a relative time since startup), you hae to do some slightly tedious parsing of the log message to get the timestamp out.

Image

```cs
builder.Eventing.Subscribe((evt, ct) =>
{
var loggerService = evt.Services.GetRequiredService();
_ = Task.Run(async () =>
{
await foreach (var logEntry in loggerService.WatchAsync(evt.Model.Resources[0]))
{
foreach (var line in logEntry)
{
LogLine
Console.WriteLine(line.Content);
}
}
});
return Task.CompletedTask;
});
```

### Describe the solution you'd like

A separate `time` field should be added from the LogLine, and the log line contents should be exactly as the app originally emitted it, not being prepended with the timestamp.

### Additional context

This will be a breaking change.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.