Add detailed logs from the MCP Server
What does this PR do?
Adds a unified, configurable logging system to help users and developers diagnose issues, inspect MCP protocol activity, and debug tool execution without requiring complex tools like PerfView or dotnet-trace. This enables clear, actionable visibility into MCP Server behavior through configurable console and file logging.
Key Changes
-
Enhanced ServiceStartCommand – Added ASP.NET Core–compliant logging configuration with CLI, environment, and appsettings hierarchy (CLI → Env → Config → Default).
-
Custom FileLoggerProvider – Added file logging with {timestamp} and {pid} placeholders and automatic directory creation.
-
New CLI options:
- --debug: Enables debug-level console logging.
- --log-level: Sets log verbosity (Trace, Debug, Information, etc.).
- --log-file: Writes logs to a specified file.
- Environment variables:
- AZMCP_LOG_LEVEL, AZMCP_LOG_FILE (custom)
- LOGGING__LOGLEVEL__DEFAULT, LOGGING__FILE__PATH (ASP.NET Core standard).
-
Routes logs to STDERR to keep MCP protocol output clean.
-
Updated live-test.yml with environment variables for automated logging
GitHub issue number?
https://github.com/microsoft/mcp/issues/142
Pre-merge Checklist
- [ ] Required for All PRs
- [ ] Read contribution guidelines
- [ ] PR title clearly describes the change
- [ ] Commit history is clean with descriptive messages (cleanup guide)
- [ ] Added comprehensive tests for new/modified functionality
- [ ] Updated
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)