Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

Fixes extra logging in non-root commands by configuring logging centrally based on command type.

Changes Made

  • Root command: Uses rich logging with ProxyConsoleFormatter (unchanged)
  • stdio command: Uses file logging only (unchanged)
  • jwt command: No console logging - all logging suppressed so only the token output is visible
  • Other subcommands (cert, config, outdated, msgraphdb): Rich logging with ProxyConsoleFormatter but with plugin messages filtered out

Added IsRootCommand property that detects if the first argument starts with - (option) or there are no arguments, automatically working for any new subcommand without code changes.

Added IsJwtCommand property to handle the jwt command's special case where no logging should be visible.

Testing

  • jwt create outputs only the token without extra logging
  • outdated shows its output correctly with rich formatting (no plugin messages)
  • cert --help and config --help work correctly
  • ✅ Root --help displays correctly with rich formatting
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG]: extra logging in non-root commands</issue_title>
<issue_description>### Description

When running non-root commands, there's extra logging which interferes with the command's output

Expected behaviour

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Ik1lZ2FuIEJvd2VuIiwic3ViIjoiTWVnYW4gQm93ZW4iLCJqdGkiOiJmMTZlOTllIiwic2NwIjoiQ3VzdG9tZXJzLlJlYWQiLCJhdWQiOiJodHRwczovL2FwaS5jb250b3NvLmNvbSIsIm5iZiI6MTc2ODU1OTUxMSwiZXhwIjoxNzY4NTU5NTExLCJpYXQiOjE3Njg1NTk1MTEsImlzcyI6ImRldi1wcm94eSJ9.VUKYcsSrHrG69R9nmBbrSx_QDZ93wzp3eAzaGJ6vkhs

Actual behaviour

 warn    AddPlugins: The version of schema does not match the installed Dev Proxy version, the expected schema is https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/rc.schema.json
 warn    The version of schema does not match the installed Dev Proxy version, the expected schema is https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/crudapiplugin.schema.json
 warn    The version of schema does not match the installed Dev Proxy version, the expected schema is https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/crudapiplugin.apifile.schema.json
 info    5 actions for CRUD API loaded from /Users/waldek/github/pnp/proxy-samples/samples/jwt-testing-toolkit/.devproxy/customers-api.json
 info    Data for CRUD API loaded from customers-data.json for API /Users/waldek/github/pnp/proxy-samples/samples/jwt-testing-toolkit/.devproxy/customers-api.json
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Ik1lZ2FuIEJvd2VuIiwic3ViIjoiTWVnYW4gQm93ZW4iLCJqdGkiOiJmMTZlOTllIiwic2NwIjoiQ3VzdG9tZXJzLlJlYWQiLCJhdWQiOiJodHRwczovL2FwaS5jb250b3NvLmNvbSIsIm5iZiI6MTc2ODU1OTUxMSwiZXhwIjoxNzY4NTU5NTExLCJpYXQiOjE3Njg1NTk1MTEsImlzcyI6ImRldi1wcm94eSJ9.VUKYcsSrHrG69R9nmBbrSx_QDZ93wzp3eAzaGJ6vkhs

Steps to reproduce

devproxy jwt create --name "Megan Bowen" --issuer "dev-proxy" --audiences "https://api.contoso.com" --scopes "Customers.Read"

Dev Proxy Version

latest from main

Operating system (environment)

macOS

Shell

zsh

Configuration file

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "CrudApiPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "customersApi"
    }
  ],
  "urlsToWatch": [
    "https://api.contoso.com/*"
  ],
  "customersApi": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/crudapiplugin.schema.json",
    "apiFile": "customers-api.json"
  }
}

Additional Info

No response</issue_description>

<agent_instructions>Configure logging so that the rich logging is used only with the root command. All other subcommands should only log their output, just like the stdio subcommand does</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix extra logging in non-root commands Fix extra logging in non-root commands Jan 17, 2026
Copilot AI requested a review from waldekmastykarz January 17, 2026 08:18
@waldekmastykarz waldekmastykarz added the pr-bugfix Fixes a bug label Jan 17, 2026
Copy link
Collaborator

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

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

@copilot is this the best way to implement this? The stdio command has something similar implemented too. Is there a way to configure it centrally and avoid duplication? Only the root command should have the extended logging. All other commands should only print console.writelines. All other logs should be invisible

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 17, 2026

@copilot is this the best way to implement this? The stdio command has something similar implemented too. Is there a way to configure it centrally and avoid duplication? Only the root command should h...

Refactored in ccf902b. The logging is now configured centrally in ILoggingBuilderExtensions.ConfigureDevProxyLogging with a single check: !DevProxyCommand.IsRootCommand. Only the root command gets rich logging; all subcommands get minimal logging with plugin messages filtered out. No duplication needed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy jwt create --name Megan Bowen --issuer dev-proxy --audiences REDACTED --scopes Customers.Read (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy outdated (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy cert --help (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Collaborator

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

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

@copilot ok, it must be done differently, because now we're surpressing all output which isn't great. jwt and stdio shouldn't log anything to console. Other commands should

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 18, 2026

@copilot ok, it must be done differently, because now we're surpressing all output which isn't great. jwt and stdio shouldn't log anything to console. Other commands should

Fixed in eb12d79. Updated the logging configuration:

  • stdio and jwt commands: No console logging
  • Root command: Rich logging with ProxyConsoleFormatter
  • Other subcommands (cert, config, outdated, msgraphdb): Simple console logging with plugin messages filtered out

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy jwt create --name Megan Bowen --issuer dev-proxy --audiences REDACTED --scopes Customers.Read (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy outdated (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy cert --help (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@waldekmastykarz
Copy link
Collaborator

@copilot is this the best way to solve it?

Copy link
Contributor Author

Copilot AI commented Jan 18, 2026

@copilot is this the best way to solve it?

The current approach is a reasonable solution given the constraint that logging must be configured early in app startup, before System.CommandLine parses commands.

An alternative would be to configure all subcommands to have no console logging by default (like stdio), and let commands that need logging output use Console.WriteLine directly. This would simplify the logic to just two cases: root command (rich logging) vs all subcommands (no logging).

Would you prefer that simpler approach? It would mean commands like cert, config, outdated would output via Console.WriteLine instead of the logger.

@waldekmastykarz
Copy link
Collaborator

@copilot let's stick with the current approach. We can always change it in the future

@waldekmastykarz waldekmastykarz marked this pull request as ready for review January 18, 2026 17:42
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner January 18, 2026 17:42
Copilot AI review requested due to automatic review settings January 18, 2026 17:42
@waldekmastykarz waldekmastykarz marked this pull request as draft January 18, 2026 17:44
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 fixes extra logging in non-root commands by configuring logging centrally based on command type. The issue was that plugin messages and other diagnostic logs were appearing in the output of utility commands like jwt create, interfering with their intended output.

Changes:

  • Added IsJwtCommand property to detect when the JWT command is being run and suppress all console logging
  • Added IsRootCommand property to detect when the root proxy command is being invoked (vs. subcommands)
  • Refactored logging configuration to use rich logging for root command, no logging for JWT command, and simple console logging with filtered plugin messages for other subcommands

Reviewed changes

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

File Description
DevProxy/Commands/DevProxyCommand.cs Added IsJwtCommand and IsRootCommand static properties to detect which command is being executed based on command-line arguments
DevProxy/Extensions/ILoggingBuilderExtensions.cs Refactored logging configuration to use conditional logic based on command type, with different logging strategies for stdio, jwt, root, and other subcommands

waldekmastykarz and others added 3 commits January 18, 2026 18:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz marked this pull request as ready for review January 18, 2026 17:50
@garrytrinder
Copy link
Contributor

devproxy outdated command is returning plugin messages.

image

@waldekmastykarz
Copy link
Collaborator

devproxy outdated command is returning plugin messages.

image

@copilot include outdated in the list of commands that should use simplified logging

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 19, 2026

devproxy outdated command is returning plugin messages.

<img alt="image" width="882" height="52" src="https://private-user-images.githubusercontent.com/11563347/537506900-16675d95-6637-471b...

Fixed in 8ecf3a4. The subcommands branch was incorrectly using the same rich logging as the root command. Now it properly uses ClearProviders() + AddSimpleConsole() with plugin messages filtered to LogLevel.None.

devproxy outdated now only shows its own output:

info: DevProxy.Commands.OutdatedCommand[0] You are using the latest version of Dev Proxy.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy outdated (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy jwt create --name Test User (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@waldekmastykarz
Copy link
Collaborator

@copilot revert the last change. For the outdated command, keep the existing logging formatting, only suppress messages from plugins.

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 19, 2026

@copilot revert the last change. For the outdated command, keep the existing logging formatting, only suppress messages from plugins.

Fixed in c7c1793. Reverted to use rich logging with ProxyConsoleFormatter for subcommands like outdated. Only plugin messages are now filtered out (DevProxy.Plugins.*LogLevel.None).

devproxy outdated now shows:

 info    You are using the latest version of Dev Proxy.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy outdated (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy jwt create --name Test User (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@waldekmastykarz waldekmastykarz merged commit fd55193 into main Jan 19, 2026
4 checks passed
@waldekmastykarz waldekmastykarz deleted the copilot/fix-extra-logging-non-root-commands branch January 19, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: extra logging in non-root commands

3 participants