Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

Clean up deployment logs

Based on the issue analysis and feedback, here are the changes made:

  • Centralize stack trace filtering in PipelineLoggerProvider

    • Created simple implementation without IOptions dependency
    • Stack traces are automatically shown/hidden based on global configuration
    • No scattered conditional checks needed throughout the codebase
  • Change command execution logs from LogInformation to LogDebug

    • "Running Docker CLI with arguments" → LogDebug (DockerContainerRuntime.cs)
    • "Running {RuntimeName} with arguments" → LogDebug (ContainerRuntimeBase.cs)
  • Fix PublishModeProvisioningContextProvider cancellation handling

    • OperationCanceledException is re-thrown without logging
  • Clean up Azure credential logging

    • Removed verbose DefaultAzureCredential warning message
    • Simplified to log only the credential type being used
    • Removed "Getting default subscription and tenant..." log message
  • Fix test compilation errors

    • Updated PipelineLoggerProviderTests to use parameterless constructor
    • Removed unused IOptions dependency from tests

Implementation Details

PipelineLoggerProvider now uses a simple approach without IOptions:

  • Parameterless constructor
  • Exception details included/excluded based on logging configuration
  • Clean separation of concerns

DistributedApplicationBuilder configures logging through standard filters:

  • Reads Publishing:LogLevel configuration
  • Applies log level filtering for PipelineLoggerProvider
  • Standard ASP.NET Core logging patterns

This eliminates the need for conditional logging checks throughout the codebase while achieving clean production logs and detailed debug logs when needed.

Benefits

  • Cleaner production logs: Command details and stack traces don't clutter normal deployment output
  • Better user experience: Users see actionable error messages instead of technical stack traces
  • Debugging still easy: Full details available when running with --verbosity debug
  • Simple implementation: No complex DI dependencies for basic logging filtering
  • Better maintainability: Easy to adjust logging behavior
  • Reduced noise: Azure credential logging is concise and consistent

Testing

  • ✅ Build succeeds with no warnings or errors
  • ✅ PipelineLoggerProvider tests pass (5/5)
  • ✅ All existing functionality preserved with cleaner implementation
Original prompt

This section details on the original issue you should resolve

<issue_title>Clean up deployment logs now that we have them</issue_title>
<issue_description> General guidance:

  • Don't show exception stack traces unless min log level is at debug
  • Running command details should be debug (see docker ls)

Specific fixes

  • Fix the warning logs in PublishModeProvisioningContextProvider, especially for cancellation
  • This is duplicated "[INF] Loading deployment state from
    .aspire\deployments\10F260DCF4A8CD0C5B329F00A1A16931049274AABA8201AF2A19FB8638DD20F5\production.json" we already show "13:45:49 (analyze-model) ✓ Deployment state will be loaded from:". We can make this debug.
aspire deploy --log-level debug
13:45:49 (display-environment) → Starting display-environment...
13:45:49 (display-environment) → Discovering target environment
13:45:49 (display-environment) ✓ Deploying to environment: production (0.0s)
13:45:49 (display-environment) ✓ display-environment completed successfully
13:45:49 (analyze-model) → Starting analyze-model...
13:45:49 (analyze-model) → Analyzing the distributed application model for publishing and deployment capabilities.
13:45:49 (analyze-model) ✓ Found deployment steps in the application pipeline. (0.0s)
13:45:49 (analyze-model) → Checking deployment state configuration.
13:45:49 (analyze-model) ✓ Deployment state will be loaded from:
<user>\.aspire\deployments\10F260DCF4A8CD0C5B329F00A1A16931049274AABA8201AF2A19FB8638DD20F5\production.json (0.0s)
13:45:49 (analyze-model) ✓ analyze-model completed successfully
13:45:49 (validate-azure-cli-login) → Starting validate-azure-cli-login...
13:45:49 (build-compute) → Starting build-compute...
13:45:49 (validate-azure-cli-login) ✓ validate-azure-cli-login completed successfully
13:45:49 (create-provisioning-context) → Starting create-provisioning-context...
13:45:49 (create-provisioning-context) i [INF] Loading deployment state from
<user>\.aspire\deployments\10F260DCF4A8CD0C5B329F00A1A16931049274AABA8201AF2A19FB8638DD20F5\production.json
13:45:49 (fetch-tenant) → Starting fetch-tenant...
13:45:49 (fetch-tenant) → Fetching available tenants
13:45:49 (build-images) → Starting build-images...
13:45:49 (build-images) → Checking Docker health
13:45:49 (build-compute) i [INF] Running Docker with arguments: container ls -n 1
13:45:50 (build-compute) i [DBG] docker (stdout): CONTAINER ID   IMAGE                                             COMMAND                  CREATED       STATUS
PORTS     NAMES
13:45:50 (build-compute) i [DBG] docker (stdout): 71863d1b3940   static:1f8dba6f9c810d72fe60f954f8f7a329655425cd   "dotnet /app/yarp.dl…"   11 days ago   Exited (2)
11 days ago             nervous_bhabha
13:45:50 (build-compute) i [INF] Docker daemon is running.
13:45:50 (build-compute) i [INF] Running Docker with arguments: buildx version
13:45:51 (build-compute) i [DBG] docker (stdout): github.com/docker/buildx v0.28.0-desktop.1 8ad457cf5e291fcb7152ef6946162cc811a2fb29
13:45:51 (build-compute) i [INF] Docker buildx is available and running.
13:45:51 (build-images) ✓ Docker is healthy. (1.6s)
13:45:51 (build-compute) i [INF] Building container image for resource app
13:45:51 (build-images) → Building image: app
13:45:51 (build-compute) i [INF] Running Docker CLI with arguments: buildx build --file "<apps>\Py12\Dockerfile" --tag
"app:5b8f2b232a83ec1aaecfb19337c5a3e0d8c23e43" --platform "linux/amd64" "<apps>\Py12"
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#0 building with "desktop-linux" instance using docker driver
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#1 [internal] load build definition from Dockerfile
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#1 transferring dockerfile: 1.80kB done
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#1 DONE 0.0s
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#2 [internal] load metadata for ghcr.io/astral-sh/uv:python3.13-bookworm-slim
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#2 DONE 0.2s
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#3 [internal] load metadata for docker.io/library/node:22-slim
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#3 DONE 0.2s
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#4 [internal] load metadata for docker.io/library/python:3.13-slim-bookworm
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#4 DONE 0.2s
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#5 [internal] load .dockerignore
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#5 transferring context: 2B done
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#5 DONE 0.0s
13:45:53 (build-compute) i [DBG] docker buildx (stderr): dotnet/aspire#6 [internal] load build context
13:45:53 (build-compute) i [D...

</details>

Fixes dotnet/aspire#12288

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/dotnet/aspire/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

…ducing verbosity

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copilot AI changed the title [WIP] Clean up deployment logs for better clarity Clean up deployment logs to reduce verbosity and conditionally show stack traces Oct 23, 2025
Copilot AI requested a review from davidfowl October 23, 2025 06:01
Copilot finished work on behalf of davidfowl October 23, 2025 06:01
@davidfowl
Copy link
Member

@copilot The detection of debug level vs not should be centralized in @dotnet/aspire/files/src/Aspire.Hosting/Pipelines/PipelineLoggerProvider.cs . We should not have if statements all over the code around stack traces vs not.

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot The detection of debug level vs not should be centralized in @dotnet/aspire/files/src/Aspire.Hosting/Pipelines/PipelineLoggerProvider.cs . We should not have if statements all over the code a...

Done! Moved the stack trace filtering logic to PipelineLoggerProvider.cs in the PipelineLogger.Log method. This eliminates all the scattered if (logger.IsEnabled(LogLevel.Debug)) checks throughout the codebase. The centralized implementation automatically filters out exception stack traces when log level is Information or higher, and includes them when log level is Debug or Trace. (commit f98a94e)

Copilot AI changed the title Clean up deployment logs to reduce verbosity and conditionally show stack traces Clean up deployment logs to reduce verbosity and centralize stack trace filtering Oct 23, 2025
Copilot finished work on behalf of davidfowl October 23, 2025 06:17
@github-actions
Copy link
Contributor

github-actions bot commented Oct 23, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12298

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12298"

@davidfowl davidfowl marked this pull request as ready for review October 23, 2025 06:43
Copilot AI review requested due to automatic review settings October 23, 2025 06:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reduces verbosity in deployment logs by moving command execution details to Debug level and centralizing exception stack trace filtering, making production logs cleaner while preserving detailed information for troubleshooting.

Key changes:

  • Command execution logging moved from Information to Debug level across container runtime classes
  • Exception stack trace filtering centralized in PipelineLoggerProvider to automatically exclude traces at Information level and above
  • Improved user experience with actionable error messages by default, full diagnostics available with --verbosity debug

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
DockerContainerRuntime.cs Changed Docker CLI command logging from Information to Debug level
ContainerRuntimeBase.cs Changed container runtime command logging from Information to Debug level in two methods
PipelineLoggerProvider.cs Added centralized exception filtering logic to exclude stack traces above Debug level

@davidfowl
Copy link
Member

@copilot Lets do more clean up of the azure logging:

Remove this block logging about DefaultAzureCredential:
@dotnet/aspire/files/src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultTokenCredentialProvider.cs

We can log the azure credential type here @dotnet/aspire/files/src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultTokenCredentialProvider.cs

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot Lets do more clean up of the azure logging:

Remove this block logging about DefaultAzureCredential:...

Done! Cleaned up Azure logging:

  • Removed the verbose DefaultAzureCredential warning block
  • Simplified to log only the credential type for all credential types
  • Removed the "Getting default subscription and tenant..." log message

All Azure credential types now log consistently: "Using {credentialType} for provisioning." (commit 36d0aab)

Copilot AI requested a review from davidfowl October 23, 2025 07:13
Copilot finished work on behalf of davidfowl October 23, 2025 07:13
@davidfowl
Copy link
Member

@copilot The PipelineLoggerProvider needs to get the configured log level from configuration see @dotnet/aspire/files/src/Aspire.Hosting/DistributedApplicationBuilder.cs and use that to filter if we show stack traces for exceptions or not. Let's create an options object called PipelineLoggingOptions that encapsulates this logic and is part of DI.

class PipelineLoggingOptions
{
public LogLevel MinimumLevel { get; set; }
public bool IncludeExceptionDetails => MinLevel >= LogLevel.Debug;
}

The changes to DistributedApplicationBuilder should look like:

_innerBuilder.Services.Configure(o =>
{
o.MinimumLogLevel = _innerBuilder.Configuration["Publishing:LogLevel"]?.ToLowerInvariant() switch
{
"trace" => LogLevel.Trace,
"debug" => LogLevel.Debug,
"info" or "information" => LogLevel.Information,
"warn" or "warning" => LogLevel.Warning,
"error" => LogLevel.Error,
"crit" or "critical" => LogLevel.Critical,
_ => LogLevel.Information
};
});

    _innerBuilder.Services.AddOptions<LoggerFilterOptions>().Configure<PipelineLoggingOptions>((filterLoggingOptions, pipelineLoggingOptions) =>
    {
        filterLoggingOptions.AddFilter<PipelineLoggerProvider>((level) => level >= pipelineLoggingOptions.MinimumLogLevel);
    });

Then PipelineLoggerProvider should inject IOptions and should use IncludeExceptionDetails to determine if the stack should be included.

…il configuration

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copilot AI requested a review from mitchdenny as a code owner October 23, 2025 19:10
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot The PipelineLoggerProvider needs to get the configured log level from configuration see @dotnet/aspire/files/src/Aspire.Hosting/DistributedApplicationBuilder.cs and use that to filter if we s...

Done! Created PipelineLoggingOptions class with MinimumLogLevel property and IncludeExceptionDetails computed property. The options are configured in DistributedApplicationBuilder from Publishing:LogLevel configuration and injected into PipelineLoggerProvider via DI. The logging filter is also configured using the options pattern as requested. (commit a69aebb)

Copilot AI changed the title Clean up deployment logs to reduce verbosity and centralize stack trace filtering Clean up deployment logs to reduce verbosity and centralize stack trace filtering with DI-based configuration Oct 23, 2025
Copilot finished work on behalf of davidfowl October 23, 2025 19:12
@davidfowl
Copy link
Member

@copilot Fix the tests D:\a\aspire\aspire\tests\Aspire.Hosting.Tests\Pipelines\PipelineLoggerProviderTests.cs(20,20): error CS1729: 'PipelineLoggerProvider' does not contain a constructor that takes 1 arguments [D:\a\aspire\aspire\tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj]
0 Warning(s)

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 24, 2025

@copilot Fix the tests D:\a\aspire\aspire\tests\Aspire.Hosting.Tests\Pipelines\PipelineLoggerProviderTests.cs(20,20): error CS1729: 'PipelineLoggerProvider' does not contain a constructor that takes 1...

Fixed! Updated PipelineLoggerProviderTests to use the parameterless constructor that matches the current implementation. Removed the obsolete IOptions parameter and unused using statement. (commit c6e1435)

Copilot AI requested a review from davidfowl October 24, 2025 03:25
Copilot finished work on behalf of davidfowl October 24, 2025 03:25
@davidfowl davidfowl merged commit 24636ae into main Oct 24, 2025
599 of 603 checks passed
@davidfowl davidfowl deleted the copilot/clean-up-deployment-logs branch October 24, 2025 05:50
@dotnet-policy-service dotnet-policy-service bot added this to the 13.0 milestone Oct 24, 2025
radical added a commit that referenced this pull request Oct 29, 2025
…ce filtering with DI-based configuration (#12298)

* Initial plan

* Clean up deployment logs by conditionally showing stack traces and reducing verbosity

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>

* Centralize stack trace filtering logic in PipelineLoggerProvider

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>

* Update src/Aspire.Hosting/Pipelines/PipelineLoggerProvider.cs

* Clean up Azure credential logging and remove verbose messages

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>

* Use PipelineLoggingOptions to centralize log level and exception detail configuration

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>

* Fix logging configuration to use IOptions for PipelineLoggingOptions

* Update src/Aspire.Hosting/Pipelines/PipelineLoggerProvider.cs

* Refactor PipelineLoggerProvider and PipelineStepContext to remove IOptions dependency and simplify logger initialization

* Change log level from Information to Debug for deployment state save confirmation

* Fix PipelineLoggerProviderTests to use parameterless constructor

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>

* Apply suggestions from code review

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: David Fowler <davidfowl@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants