Class MicrosoftLoggingBuilderExtensions
Extensions for the configuration builder for logging.
Usage
Either configure a CacheManager specific logger factory:
var builder = new Core.ConfigurationBuilder("myCache");
builder.WithMicrosoftLogging(f =>
{
f.AddConsole(LogLevel.Information);
f.AddDebug(LogLevel.Verbose);
});
Or pass in an existing ILoggerFactory
:
var builder = new Core.ConfigurationBuilder("myCache");
builder.WithMicrosoftLogging(loggerFactory);
Inherited Members
Namespace:CacheManager.Core
Assembly:CacheManager.Microsoft.Extensions.Logging.dll
Syntax
public static class MicrosoftLoggingBuilderExtensions
Remarks
To use the different log providers, install the corresponding Microsoft.Extensions.Logging.*
package.
Methods
| Improve this Doc View SourceWithMicrosoftLogging(ConfigurationBuilderCachePart, IServiceCollection)
Configures cache manager logging to use a Microsoft.Extensions.Logging.ILoggerFactory
which gets resolved from the serviceCollection.
Declaration
public static ConfigurationBuilderCachePart WithMicrosoftLogging(this ConfigurationBuilderCachePart part, IServiceCollection serviceCollection)
Parameters
Type | Name | Description |
---|---|---|
ConfigurationBuilderCachePart | part | The builder part. |
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | The services collection. |
Returns
Type | Description |
---|---|
ConfigurationBuilderCachePart | The builder. |
WithMicrosoftLogging(ConfigurationBuilderCachePart, ILoggerFactory)
Enables logging for the cache manager instance using an existion Microsoft.Extensions.Logging.ILoggerFactory
as target.
Declaration
public static ConfigurationBuilderCachePart WithMicrosoftLogging(this ConfigurationBuilderCachePart part, ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
ConfigurationBuilderCachePart | part | The builder part. |
Microsoft.Extensions.Logging.ILoggerFactory | loggerFactory | The logger factory which should be used. |
Returns
Type | Description |
---|---|
ConfigurationBuilderCachePart | The builder. |
WithMicrosoftLogging(ConfigurationBuilderCachePart, Action<ILoggerFactory>)
Enables logging for the cache manager instance.
Using this extension will create a NEW instance of Microsoft.Extensions.Logging.ILoggerFactory
.
If you use the standard Micorosft AspNetCore DI, you might want to use the other extensions which make CacheManager use the already injected/shared instance of Microsoft.Extensions.Logging.ILoggerFactory.
Use the factory to configure the logger factory and add Microsoft.Extensions.Logging.ILoggerProviders as needed.
Declaration
public static ConfigurationBuilderCachePart WithMicrosoftLogging(this ConfigurationBuilderCachePart part, Action<ILoggerFactory> factory)
Parameters
Type | Name | Description |
---|---|---|
ConfigurationBuilderCachePart | part | The builder part. |
Action<Microsoft.Extensions.Logging.ILoggerFactory> | factory | The logger factory used for configuring logging. |
Returns
Type | Description |
---|---|
ConfigurationBuilderCachePart | The builder. |