Home

ILoggerProvider

ILoggerProvider is an interface in the Microsoft.Extensions.Logging namespace that represents a logging provider capable of creating loggers for a given category and managing its resources. It is implemented by concrete logging providers such as ConsoleLoggerProvider, DebugLoggerProvider, and file-based providers. Providers are discovered and registered with an ILoggerFactory, which aggregates multiple providers and uses them to produce loggers for categories.

The interface declares a single method: ILogger CreateLogger(string categoryName). This method returns an ILogger instance that

Purpose and behavior: A provider encapsulates the destination and formatting of log output. It is responsible

Lifecycle and usage: In typical applications, loggers are obtained from an ILoggerFactory. The factory maintains a

Implementation notes: Implementations should be thread-safe and efficient, since log calls occur frequently. Custom providers can

will
receive
log
messages
for
the
specified
category.
ILoggerProvider
also
inherits
from
IDisposable,
so
providers
typically
implement
Dispose
to
release
resources
or
flush
buffers
when
the
factory
is
disposed.
for
translating
the
generic
log
requests
from
an
ILogger
into
concrete
writes
to
a
sink
(such
as
the
console,
a
file,
or
a
telemetry
system).
The
provider
can
apply
category-based
or
scope-based
configurations
and
may
maintain
internal
state
across
logs,
such
as
open
file
handles
or
buffers.
collection
of
ILoggerProvider
instances
and
delegates
the
creation
of
loggers
to
them.
When
a
logger
is
created
for
a
category,
the
providers
collectively
determine
how
log
messages
are
processed
and
written.
When
the
factory
is
disposed,
its
providers
are
disposed
as
well.
be
added
via
dependency
injection
or
configuration,
enabling
extensibility
of
the
logging
system.