Skip to content

Conversation

@anannya03
Copy link
Contributor

@anannya03 anannya03 commented Oct 13, 2025

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:

  1. --debug: Enables debug-level console logging.
  2. --log-level: Sets log verbosity (Trace, Debug, Information, etc.).
  3. --log-file: Writes logs to a specified file.
  • Environment variables:
  1. AZMCP_LOG_LEVEL, AZMCP_LOG_FILE (custom)
  2. 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?

#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.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables detailed MCP Server logging for live test visibility by adding comprehensive logging configuration options. The changes allow tests to capture logs through both verbose stderr output and file-based logging without requiring additional debugging tools.

Key changes:

  • Added configurable logging levels and verbose mode through command line options and environment variables
  • Implemented file-based logging with placeholder support for timestamps and process IDs
  • Enhanced logging configuration for both STDIO and HTTP server modes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
SimpleFileLoggerProvider.cs New lightweight file logger implementation for structured log output
ServiceStartOptions.cs Added logging configuration properties (LogLevel, Verbose, LogFile)
ServiceOptionDefinitions.cs Defined new command line options for logging controls
ServiceStartCommand.cs Integrated logging options with environment variable support and enhanced logging setup
Comments suppressed due to low confidence (1)

core/Azure.Mcp.Core/src/Services/Logging/SimpleFileLoggerProvider.cs:1

  • The Verbose option should be of type Option instead of Option<string?> since it represents a boolean flag. The DefaultValueFactory should return a boolean value false instead of the string "false".
// Copyright (c) Microsoft Corporation.

@anannya03 anannya03 marked this pull request as draft October 13, 2025 04:03
@g2vinay g2vinay added the Do Not Merge Do Not Merge / WIP PRs label Oct 13, 2025
@joshfree joshfree moved this from Untriaged to In Progress in Azure MCP Server Oct 14, 2025
@joshfree joshfree added this to the 2025-11 milestone Oct 14, 2025
@anannya03 anannya03 force-pushed the live-tests-debug_logs branch from 84b2be2 to dffbee1 Compare October 15, 2025 04:05
{
logging.ClearProviders();
logging.ConfigureOpenTelemetryLogger();
logging.AddEventSourceLogger();
Copy link
Member

@conniey conniey Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a conversation offline if it is easier but I was hoping that we wouldn't have to add these switches.

Using a custom ILogger, we can leverage existing infrastructure to output logs. The user experience here is to do azmcp.exe server start --log-level debug. But this only applies to the logger we wrote, the settings won't also apply to the "EventSourceLogger" or any other ILogger.

I was hoping that an end user would be able to do something like:

set Logging__LogLevel__Default=Debug
./azmcp.exe server start

And this log level would apply to your new logger, and also the EventSourceLogger, any other Console logger, possibly a file logger if there is one.

Or they can use the same configuration system to be more granular about their logging. There's a bigger example here: Configure Logging

The bonus would be that they wouldn't have to learn something new about our logging because it uses the same configuration as other .NET loggers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if you used the [ProviderAlias("AzureMcpDebugLogger")] or something, they could configure our logger via:

set Logging__AzureMcpDebugLogger__LogLevel=Debug

@joshfree joshfree removed the Do Not Merge Do Not Merge / WIP PRs label Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants