V2 Edit pass (#1728)
This commit is contained in:
parent
2d1b9a3462
commit
b283596df1
1 changed files with 263 additions and 251 deletions
|
|
@ -20,16 +20,16 @@ MCP uses the logging levels defined in [RFC 5424](https://datatracker.ietf.org/d
|
|||
The MCP C# SDK uses the standard .NET [ILogger] and [ILoggerProvider] abstractions, which support a slightly
|
||||
different set of logging levels. The following table shows the levels and how they map to standard .NET logging levels.
|
||||
|
||||
| Level | .NET | Description | Example Use Case |
|
||||
|-----------|------|-----------------------------------|------------------------------|
|
||||
| debug | ✓ | Detailed debugging information | Function entry/exit points |
|
||||
| info | ✓ | General informational messages | Operation progress updates |
|
||||
| notice | | Normal but significant events | Configuration changes |
|
||||
| warning | ✓ | Warning conditions | Deprecated feature usage |
|
||||
| error | ✓ | Error conditions | Operation failures |
|
||||
| critical | ✓ | Critical conditions | System component failures |
|
||||
| alert | | Action must be taken immediately | Data corruption detected |
|
||||
| emergency | | System is unusable | |
|
||||
| Level | .NET | Description | Example use case |
|
||||
|-------------|------|----------------------------------|----------------------------|
|
||||
| `debug` | ✓ | Detailed debugging information | Function entry/exit points |
|
||||
| `info` | ✓ | General informational messages | Operation progress updates |
|
||||
| `notice` | | Normal but significant events | Configuration changes |
|
||||
| `warning` | ✓ | Warning conditions | Deprecated feature usage |
|
||||
| `error` | ✓ | Error conditions | Operation failures |
|
||||
| `critical` | ✓ | Critical conditions | System component failures |
|
||||
| `alert` | | Action must be taken immediately | Data corruption detected |
|
||||
| `emergency` | | System is unusable | |
|
||||
|
||||
**Note:** .NET's [ILogger] also supports a `Trace` level (more verbose than Debug) log level.
|
||||
As there is no equivalent level in the MCP logging levels, Trace level logs messages are silently
|
||||
|
|
@ -51,7 +51,7 @@ messages as there might not be an open connection to the client on which the log
|
|||
|
||||
The C# SDK provides an extension method <xref:Microsoft.Extensions.DependencyInjection.McpServerBuilderExtensions.WithSetLoggingLevelHandler*> on <xref:Microsoft.Extensions.DependencyInjection.IMcpServerBuilder> to allow the
|
||||
server to perform any special logic it wants to perform when a client sets the logging level. However, the
|
||||
SDK already takes care of setting the <xref:ModelContextProtocol.Server.McpServer.LoggingLevel> in the <xref:ModelContextProtocol.Server.McpServer>, so most servers will not need to
|
||||
SDK already takes care of setting the <xref:ModelContextProtocol.Server.McpServer.LoggingLevel> in the <xref:ModelContextProtocol.Server.McpServer>, so most servers don't need to
|
||||
implement this.
|
||||
|
||||
MCP Servers using the MCP C# SDK can obtain an [ILoggerProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerprovider) from the <xref:ModelContextProtocol.Server.McpServer.AsClientLoggerProvider> method on <xref:ModelContextProtocol.Server.McpServer>,
|
||||
|
|
@ -74,7 +74,7 @@ to send all log messages or none—this is not specified in the protocol. So
|
|||
sets a logging level to ensure it receives the desired log messages and only those messages.
|
||||
|
||||
The `loggingLevel` set by the client is an MCP logging level.
|
||||
See the [Logging Levels](#logging-levels) section above for the mapping between MCP and .NET logging levels.
|
||||
For the mapping between MCP and .NET logging levels, see the [Logging Levels](#logging-levels) section.
|
||||
|
||||
[!code-csharp[](samples/client/Program.cs?name=snippet_LoggingLevel)]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue