Log ConsoleInteractionService output to CLI log file#15521
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15521Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15521" |
There was a problem hiding this comment.
Pull request overview
Adds diagnostic logging for ConsoleInteractionService so interactive CLI output (prompts, status, messages, etc.) is captured in the CLI log files under ~/.aspire/logs/, using separate logger categories for stdout vs stderr.
Changes:
- Inject
ILoggerFactoryintoConsoleInteractionServiceand log key interaction events/messages. - Update CLI DI wiring in
Program.csto passILoggerFactorywhen constructing interaction services (extension + non-extension paths). - Update tests/helpers to provide a logger factory (
NullLoggerFactory.Instance) where needed.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Interaction/ConsoleInteractionService.cs | Introduces stdout/stderr loggers and logs interaction output/events. |
| src/Aspire.Cli/Program.cs | Passes ILoggerFactory into ConsoleInteractionService from DI. |
| tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs | Updates test DI factory to provide ILoggerFactory to interaction service. |
| tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs | Updates tests to construct interaction service with NullLoggerFactory.Instance. |
|
I'm not too concerned about security here, its a local log file and its not like we are writing secrets or anything. The place to not log secrets is where you log the secret. |
mitchdenny
left a comment
There was a problem hiding this comment.
I like the extra logging detail.
5fb63be to
399d42e
Compare
|
🎬 CLI E2E Test Recordings — 49 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23527001476 |

Description
Log ConsoleInteractionService output to the CLI log file so that console interactions (status messages, text output, prompts, selections, errors, etc.) are captured in the diagnostic log at
~/.aspire/logs/.Two ILogger categories are used to distinguish stdout vs stderr output:
Aspire.Cli.Console.Stdout- messages routed to stdoutAspire.Cli.Console.Stderr- messages routed to stderrAll messages are logged at Information level. Since the FileLoggerProvider is always active, these appear automatically in CLI log files.
Changes
ILoggerFactoryin constructor, create two loggers with stdout/stderr categories, log key interactions (status, prompts, selections, confirmations, errors, display messages, console logs, output lines)ILoggerFactoryfrom DI and pass toConsoleInteractionServicein both extension and non-extension code pathsCliTestHelper.csandConsoleInteractionServiceTests.csto passNullLoggerFactory.InstanceChecklist