aspire logs command
aspire logs - Display logs from resources in a running apphost.
Synopsis
Section titled “Synopsis”aspire logs [<resource>] [options]Description
Section titled “Description”The aspire logs command displays console logs from resources in a running AppHost. You can view logs for all resources, filter to a specific resource, follow new log entries in real time, search log content with full-text filtering, and choose table or JSON output for automation. Hidden resources are excluded by default; use the --include-hidden option to show their logs.
When executed without the --apphost option, the command:
- Scans for all running AppHost processes.
- If multiple AppHosts are running within the current directory scope, prompts you to select which one to target.
- If only one AppHost is running in scope, connects to it directly.
- If no in-scope AppHosts are found but out-of-scope AppHosts exist, displays all running AppHosts for selection.
Arguments
Section titled “Arguments”-
<resource>The name of the resource to get logs for. If not specified, logs from all resources are shown.
Options
Section titled “Options”The following options are available:
-
--apphost <apphost>The path to the Aspire AppHost file or project file, such as
apphost.mts,apphost.cs, or an AppHost.csproj. -
-f, --followStream logs in real time as they are written.
-
--format <Json|Table>Output format. Use
Jsonfor machine-readable output suitable for scripting and automation. Defaults toTable. -
-n, --tail <tail>Number of lines to show from the end of the logs.
-
-s, --search <search>Full-text search to filter log content. Only log lines whose message or resource name contains the specified text are shown. Multiple words are treated as separate fragments that must all match. Use quoted phrases to match exact multi-word text (for example,
--search '"connection timeout"'). For more information, see Search and filter. -
-t, --timestampsShow timestamps for each log line.
-
--include-hiddenIncludes resources that are marked as hidden. By default, hidden resources are not shown. When a specific resource name is provided, hidden resources are always included regardless of this option.
-
-?, -h, --helpPrints help and usage documentation for the available commands and options.
-
-l, --log-level <Critical|Debug|Error|Information|None|Trace|Warning>Set the minimum log level for console output. Use this option to increase diagnostics while troubleshooting or reduce output in scripted runs.
-
--non-interactiveRun the command in non-interactive mode, disabling all interactive prompts and spinners.
-
--nologoSuppress the startup banner and telemetry notice.
-
--bannerDisplay the animated Aspire CLI welcome banner.
-
--wait-for-debuggerWait for a debugger to attach before running a command.
Examples
Section titled “Examples”-
Show logs for all resources:
Aspire CLI aspire logs -
Show logs for a specific resource:
Aspire CLI aspire logs webfrontend -
Follow logs in real time:
Aspire CLI aspire logs --follow -
Show the last 100 log lines with timestamps:
Aspire CLI aspire logs apiservice --tail 100 --timestamps -
Output logs as JSON:
Aspire CLI aspire logs --format Json -
Show logs including hidden resources:
Aspire CLI aspire logs --include-hidden -
Filter logs by search text:
Aspire CLI aspire logs --search "error" -
Search with multiple words (all must match):
Aspire CLI aspire logs --search "connection failed" -
Search for an exact phrase using quotes:
Aspire CLI aspire logs --search '"connection timeout"' -
Search logs for a specific resource and show only the last 75 matching lines:
Aspire CLI aspire logs producer --search needle --tail 75