Class ServicesRegistrationExtension
- Namespace
- Arc4u.Dependency
- Assembly
- Arc4u.Diagnostics.dll
Extension methods to register the Arc4u logging on an IServiceCollection.
public static class ServicesRegistrationExtension
- Inheritance
-
ServicesRegistrationExtension
- Inherited Members
Methods
AddILogger(IServiceCollection)
Registers the Arc4u logging: ILogger<TCategoryName> is replaced by LoggerWrapper<T> (transient),
and the non-generic ILogger resolves to ILogger<DefaultLogger> (transient). Any existing ILogger<TCategoryName> registration is removed first.
Unless already registered, a NullLoggerProperties is registered as IAddPropertiesToLog under the keys "Scoped" and "Transient":
a logger resolved in a scope uses the "Scoped" provider, a logger resolved from the root (for a singleton) the "Transient" one.
The registered loggers expose the fluent API of ILoggerExtensions (Technical(), Business(), Monitoring()), which also works on the
non-generic ILogger so that static classes can log by passing the type with Technical(Type) or Technical<T>().
public static IServiceCollection AddILogger(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Examples
builder.Services.AddILogger();