Skip to main content
Stream and inspect logs from your deployed Microsoft Foundry hosted agent for troubleshooting and observability. You learn how to view console logs, stream in real time, inspect system events, filter by session, and recognize common log patterns.

Prerequisites

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 --follow to 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 --follow for real-time streaming:
    To find session IDs, check the output of azd 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:
  1. Stream logs in one terminal:
  2. Send a request in another terminal:
  3. Watch the logs for error patterns or unexpected behavior.
  4. Check system events if the agent seems unresponsive:
For a comprehensive debugging workflow, see Debug a hosted agent.