Skip to content

Service registration

This library contributes exactly one registration extension method, WebHostBuilderExtensions.UseSaifLog(IWebHostBuilder), which delegates directly to Serilog's own UseSerilog() host-builder extension and adds no logic of its own; everything else a consuming application needs to use this library — resolving ISaifLogService/ISaifWindowsServiceLogService/IConsoleLogService from DI and calling the corresponding Configure method — is registered and performed outside this library, by SAIF.NetCore.ServiceExtensions and by the host application itself.

Registration extension catalog

Extension methods a consuming application calls to register this library's services.

Extension method Hosting context Parameters Source
UseSaifLog(this IWebHostBuilder builder) web builder — the IWebHostBuilder being configured. Returns builder.UseSerilog(), the same IWebHostBuilder with Serilog registered as its logging provider. src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/Web/WebHostBuilderExtensions.cs

No IHostBuilder overload, no IServiceCollection extension, and no ClearProviders() call exist in this library; UseSaifLog is the single public member of WebHostBuilderExtensions (see OP-11).

Service registration catalog

This library defines no IServiceCollection registration methods of its own, so it registers no services directly. The three logger implementations this library ships are registered and configured by externally-owned components, with different owners per host style:

Implementation Interface Registered by Registration call Lifetime Configured by
SaifLog ISaifLogService SAIF.NetCore.ServiceExtensions, IServiceCollectionExtensions.RegisterLoggingService services.AddSingleton<ISaifLogService, SaifLog>() Singleton SAIF.NetCore.ServiceExtensions's IAppBuilderExtensions.ConfigureSaifLogger (called from the host's Startup.Configure), which resolves ISaifLogService/IEnvironmentClient/IHttpJsonClient/IHttpContextAccessor from DI and calls SaifLog.Configure(environmentClient, apiLogClient, contextAccessor).
SaifWindowsServiceLog ISaifWindowsServiceLogService SAIF.NetCore.ServiceExtensions, IServiceCollectionExtensions services.AddSingleton<ISaifWindowsServiceLogService, SaifWindowsServiceLog>() Singleton SAIF.NetCore.WindowsService's ServiceProgramRunnerBase.ConfigureLogger, which resolves ISaifWindowsServiceLogService/IEnvironmentClient/IHttpJsonClient from the built IHost and calls logger.Configure(envClient, httpClient). This is a different owning package from the web path above.
ConsoleLogService IConsoleLogService SAIF.NetCore.ServiceExtensions, IHostBuilderExtensions.BuildSaifConsoleApp services.AddSingleton<IConsoleLogService, ConsoleLogService>() Singleton Nobody — ConsoleLogService self-configures inline in its own constructor; no external Configure call exists for this host style.

Consult SAIF.NetCore.ServiceExtensions's own service-registration documentation for that package's full registration surface; the rows above are the entries specific to this library's three logger types, cited directly against SAIF.NetCore.ServiceExtensions/SAIF.NetCore.WindowsService source rather than inferred.

Startup base classes

None. This library defines no base class that a consuming application inherits from to bootstrap its host.

Middleware pipeline

None. UseSaifLog configures the host builder's logging provider; it registers no ASP.NET Core middleware and builds no request pipeline.

Hosted services and health checks

None. This library defines no IHostedService/BackgroundService implementation and no health check.

Required-but-not-registered services

Services this library's types resolve that UseSaifLog itself does not register — the host (via SAIF.NetCore.ServiceExtensions or SAIF.NetCore.WindowsService) must supply these before the corresponding logger's Configure method is called, or before the logger's own constructor runs.

Service type Consumer Expected source
IConfiguration All three loggers' constructors (SaifLogBase(IConfiguration, ILogger<ISaifLoggable>)) Host default (IConfiguration is always available from the generic host).
ILogger<T> (Microsoft.Extensions.Logging) All three loggers' constructors Host default (Microsoft.Extensions.Logging is always available from the generic host).
IEnvironmentClient SaifLog.Configure, SaifWindowsServiceLog.Configure, ConsoleLogService constructor SAIF.NetCore.ServiceExtensions / host application (via SAIF.NetCore.EnvironmentClient)
IHttpJsonClient SaifLog.Configure, SaifWindowsServiceLog.Configure SAIF.NetCore.ServiceExtensions / host application
IHttpContextAccessor SaifLog.Configure Host application (typically via AddHttpContextAccessor())

Sources

  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/Web/WebHostBuilderExtensions.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SaifLog.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SaifWindowsServiceLog.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/ConsoleLogService.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SaifLogBase.cs
  • src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/IServiceCollectionExtensions.cs
  • src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/IHostBuilderExtensions.cs
  • src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/IAppBuilderExtensions.cs
  • src/SAIF.NetCore.WindowsService/SAIF.NetCore.WindowsService/SAIF.NetCore.WindowsService/ServiceProgramRunnerBase.cs