Prerequisites
- A deployed hosted agent. To deploy one, see Deploy a hosted agent.
- The azd Foundry extensions installed. For installation steps, see Install the azd Foundry extensions.
- An authenticated Azure Developer CLI session. Run
azd auth loginif needed. - For session-specific logs, a session ID from an
azd ai agent invokeresponse. To invoke an agent, see Invoke a hosted agent with the Azure Developer CLI.
View recent console logs
-
Fetch recent console logs:
This command fetches recent console logs, including stdout and stderr, from the agent’s last invoke session. If no session exists, it streams container logs. The command exits after fetching the available logs. Use
--followto stream continuously.
Stream logs in real time
-
Stream logs continuously:
Press Ctrl+C to stop. This is the most useful mode for debugging. Run it in one terminal while sending requests in another.
View system event logs
-
Show container lifecycle events instead of console output:
Use system event logs to diagnose container crashes, restart loops, and resource issues.
View session-specific logs
-
Filter logs to a specific agent session:
-
Combine with
--followfor real-time streaming:To find session IDs, check the output ofazd ai agent invoke. It prints the session ID for each request.
Control log length
-
Show the last 100 lines:
The range is 1-300. The default is 50.
Monitor a specific agent
-
In multi-service projects, pass the agent name:
Recognize common log patterns
Follow a debugging workflow
A typical debugging session looks like this:-
Stream logs in one terminal:
-
Send a request in another terminal:
- Watch the logs for error patterns or unexpected behavior.
-
Check system events if the agent seems unresponsive:
Related content
- Debug a hosted agent for step-by-step diagnostic workflows.
- Test a hosted agent for validation strategies before production.
- Isolate hosted agent sessions per user for logs in isolated sessions.