Skip to content

Redirect logs to the Aspire.NET console window #9164

Answered by afscrome
btastic asked this question in Q&A
Discussion options

You must be logged in to vote

If you want all logs forwarded, then enable resource logging when creating the DistributedApplication. Logs are then forwarded to the {hostEnvironment.ApplicationName}.Resources.{resource.Name} log source

   DistributedApplication.CreateBuilder(new DistributedApplicationOptions
   {
      EnableResourceLogging = true
   })

Note this will log output from all resources and may be an explosion of logs interleaved together. If you want more granular control, take a look at the ResourceLoggerService.WatchAsync(...) methods to watch logs and then do whatever you want with them. (e.g. filter then forward to a generic ILogger to show them in the main console.)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by davidfowl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #9162 on May 08, 2025 14:29.