Class LoggerPipelineExtensions
- Namespace
- IceRpc
- Assembly
- IceRpc.Logger.dll
Provides an extension method for Pipeline to add the logger interceptor.
public static class LoggerPipelineExtensions
- Inheritance
-
LoggerPipelineExtensions
- Inherited Members
Methods
UseLogger(Pipeline, ILoggerFactory)
Adds a LoggerInterceptor to this pipeline.
public static Pipeline UseLogger(this Pipeline pipeline, ILoggerFactory loggerFactory)
Parameters
pipeline
PipelineThe pipeline being configured.
loggerFactory
ILoggerFactoryThe logger factory used to create a ILogger<TCategoryName> for LoggerInterceptor.
Returns
- Pipeline
The pipeline being configured.
Examples
The following code adds the logger interceptor to the invocation pipeline.
// Create a simple console logger factory and configure the log level for category IceRpc.
using ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
builder
.AddSimpleConsole()
.AddFilter("IceRpc", LogLevel.Debug));
// Create a client connection that logs messages to a logger with category IceRpc.ClientConnection.
await using var connection = new ClientConnection(
new Uri("icerpc://localhost"),
logger: loggerFactory.CreateLogger<ClientConnection>());
// Create an invocation pipeline and install the logger interceptor. This interceptor logs invocations using
// category `IceRpc.Logger.LoggerInterceptor`.
Pipeline pipeline = new Pipeline()
.UseLogger(loggerFactory)
.Into(connection);
- See Also