InvergeDocs
.NETAPI reference

Dependency injection & ILogger

Dependency injection & ILogger in the .NET SDK.

SymbolKindSummary
NexusLoggerProviderclassAn ILogger provider that writes to the Nexus logs product.
NexusLoggingOptionsclassControls what the NexusLoggerProvider forwards.
NexusServiceCollectionExtensionsstatic classRegisters the Nexus client in a dependency-injection container.

NexusLoggerProvider

class Inverge.Nexus.Extensions.Logging
class Inverge.Nexus.Extensions.Logging.NexusLoggerProvider

An ILogger provider that writes to the Nexus logs product.

Register it with builder.Logging.AddNexus(). Every existing logger.LogInformation(...) in the application then lands in Nexus with no call-site changes, and records carrying an exception also become grouped issues in error monitoring.

NexusLoggerProvider

constructor
new NexusLoggerProvider(IServiceProvider services, IOptions<NexusLoggingOptions> options)

Creates the provider.

Parameters

Prop

Type

CreateLogger()

method
ILogger CreateLogger(string categoryName)

Parameters

Prop

Type

Returns ILogger

Dispose()

method
void Dispose()

Releases the provider's loggers.

The client is not disposed here. It is a container singleton with its own lifetime, and the logging provider is usually torn down first — disposing it from here would stop telemetry while the rest of the application is still shutting down and still producing it.

SetScopeProvider()

method
void SetScopeProvider(IExternalScopeProvider scopeProvider)

Parameters

Prop

Type

NexusLoggingOptions

class Inverge.Nexus.Extensions.Logging
class Inverge.Nexus.Extensions.Logging.NexusLoggingOptions

Controls what the NexusLoggerProvider forwards.

NexusLoggingOptions

constructor
new NexusLoggingOptions()

CaptureExceptions

property
bool CaptureExceptions { get; set; }

Also report records that carry an exception to error monitoring, so a plain logger.LogError(ex, ...) produces a grouped, stack-traced issue.

ExcludedCategoryPrefixes

property
string[] ExcludedCategoryPrefixes { get; set; }

Category prefixes never forwarded.

Inverge.Nexus is excluded unconditionally and is not listed here: the SDK's own diagnostics must never become Nexus log lines, because delivering them would produce more of them.

IncludeEventId

property
bool IncludeEventId { get; set; }

Include the event id, when the call site set one.

IncludeScopes

property
bool IncludeScopes { get; set; }

Include the active logging scopes in each line's context.

In ASP.NET Core this is what carries the request id and route into the log line, which is usually the difference between a searchable log and a wall of text.

MinimumLevel

property
LogLevel MinimumLevel { get; set; }

The lowest level forwarded to Nexus.

This is a second gate on top of the logging framework's own filters, so you can keep Debug in the console while sending only Information and above over the network — logs are billed per line.

NexusServiceCollectionExtensions

static class Inverge.Nexus.Extensions.Logging
static class Inverge.Nexus.Extensions.Logging.NexusServiceCollectionExtensions

Registers the Nexus client in a dependency-injection container.

ConstantDescription
const string DefaultConfigurationSection = "Nexus"The configuration section bound by default.
const string HttpClientName = "Inverge.Nexus"The named HttpClient the SDK sends through.

AddNexus()

extension method
static IServiceCollection AddNexus(IServiceCollection services, Action<NexusOptions>? configure = null, string? configurationSection = "Nexus")

Registers INexusClient as a singleton.

Options are read from the Nexus configuration section first, then the NEXUS_* environment, then configure. Code wins over the environment, and the environment wins over appsettings — so a container can be re-keyed or retuned without a rebuild.

The client sends through a named IHttpClientFactory client, so the application's own handlers, resilience policies and connection lifetime apply. A hosted service flushes buffered telemetry on shutdown.

Parameters

Prop

Type

Returns IServiceCollection

AddNexus()

extension method
static IServiceCollection AddNexus(IServiceCollection services, Action<NexusOptions>? configure, Action<NexusLoggingOptions>? configureLogging, string? configurationSection = "Nexus")

Registers the client and forwards ILogger records to Nexus in one call.

Parameters

Prop

Type

Returns IServiceCollection

AddNexus()

extension method
static ILoggingBuilder AddNexus(ILoggingBuilder builder, Action<NexusLoggingOptions>? configure = null)

Forwards ILogger records to the Nexus logs product, and records carrying an exception to error monitoring.

Call AddNexus as well — this adds the bridge, not the client it writes through.

Parameters

Prop

Type

Returns ILoggingBuilder

On this page