Skip to main content

IsoplaneLoggerProvider class

Sends the messages an application writes with .NET's ILogger to the application's log.

public sealed class IsoplaneLoggerProvider : ILoggerProvider, ISupportExternalScope

Public Members​

namedescription
IsoplaneLoggerProvider()Creates a provider. Its loggers work only while the application runs under Isoplane.
CreateLogger(…)Creates a logger whose records include the supplied category.
Dispose()Releases the provider; no host resources are retained.
SetScopeProvider(…)Uses the supplied scope provider for subsequently emitted records.

Remarks​

An ASP.NET application does not create one. IsoplaneHosting.CreateBuilder registers it, so inject ILogger<T> or use app.Logger as in any ASP.NET application, and set log levels in the Logging configuration section.

In an application written without ASP.NET, Console.WriteLine already writes to the same log. Create a provider there only when you want what ILogger adds: levels, categories and named values. A logger from a provider you create writes every level except None. Use it there in place of the console logger from Microsoft.Extensions.Logging.Console, which starts a thread when it is created and so fails wherever Isoplane.AspNetCore has not replaced it, which is outside an ASP.NET application and in one that sets another dependency injection container with UseServiceProviderFactory.

While developing, the log appears in the terminal running the application. A message logged at Critical is recorded at the log's error level. Do not log credentials or connection strings.

Examples​

In an application written without ASP.NET:

using Isoplane;
using Microsoft.Extensions.Logging;

public static class Handler
{
private static readonly ILogger Log = new IsoplaneLoggerProvider().CreateLogger("Orders");

[HttpHandler]
public static Task<Response> HandleAsync(Request request)
{
Log.LogInformation("Handling {Path}", request.Path);
return Task.FromResult(Response.Text("ok"));
}
}

See Also​