Blazor.Extensions.Logging 0.1.11

Blazor Extensions Logging

Microsoft Extension Logging implementation for ASP.NET Core Blazor.

This package is considered a SemVer 2.0.0 package as it has a package dependency on SemVer 2.0.0 package(s).
This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual Studio 2017 (version 15.3) and above or NuGet client 4.3.0 and above. Read more
Install-Package Blazor.Extensions.Logging -Version 0.1.11
dotnet add package Blazor.Extensions.Logging --version 0.1.11
<PackageReference Include="Blazor.Extensions.Logging" Version="0.1.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blazor.Extensions.Logging --version 0.1.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Blazor Extensions Logging

This package is an implementation for the Microsoft Extensions Logging abstraction to support
using the ILogger interface in your Blazor code.

When the component is configured, all the log statements will appear in the browser's developer tools console.

Features

Content to log

The logger supports the same string formatting that MEL provides, together with named parameter replacement in the message.

Additionaly, you're able to log an object in the browser console. You can expand members and hierachies to see what's contained within.

If you want to log an enumerable list of objects, then the browser side component will display it by calling console.table.

Filtering

The implementation supports the ILoggerFactory-based filtering configuration that is supplied by the Microsoft Extension Logging abstraction.

To keep it lightweight, Microsoft Extensions Configuration based configuration is not supported; the logger can be only configured in code.

Log levels

The logger supports the LogLevels defined in MEL.

Some of the log levels are not available as distinct methods in the browser's developer tool, so the browser side component does some mapping.

Sample configuration

Setup

The following snippet shows how to setup the browser console logger by registering it for dependency injection in the Startup.cs of the application.

public void ConfigureServices(IServiceCollection services)
{
    services.AddLogging(builder => builder
        .AddBrowserConsole() // Add Blazor.Extensions.Logging.BrowserConsoleLogger
        .SetMinimumLevel(LogLevel.Trace)
    );
}

Usage

The following snippet shows how to consume the logger in a Blazor component.

@inject ILogger<Index> logger

@functions {
  protected override async Task OnInitAsync()
  {
      logger.LogDebug("MyComponent init");
  }
}

If you want to consume it outside of a cshtml based component, then you can use the Inject attribute to inject it into the class.

[Inject]
protected ILogger<MyClass> Logger {get;set;}

public void LogSomething()
{
  Logger.LogDebug("Inside LogSomething");
}

Contributions and feedback

Please feel free to use the component, open issues, fix bugs or provide feedback.

Contributors

The following people are the maintainers of the Blazor Extensions projects:

Blazor Extensions Logging

This package is an implementation for the Microsoft Extensions Logging abstraction to support
using the ILogger interface in your Blazor code.

When the component is configured, all the log statements will appear in the browser's developer tools console.

Features

Content to log

The logger supports the same string formatting that MEL provides, together with named parameter replacement in the message.

Additionaly, you're able to log an object in the browser console. You can expand members and hierachies to see what's contained within.

If you want to log an enumerable list of objects, then the browser side component will display it by calling console.table.

Filtering

The implementation supports the ILoggerFactory-based filtering configuration that is supplied by the Microsoft Extension Logging abstraction.

To keep it lightweight, Microsoft Extensions Configuration based configuration is not supported; the logger can be only configured in code.

Log levels

The logger supports the LogLevels defined in MEL.

Some of the log levels are not available as distinct methods in the browser's developer tool, so the browser side component does some mapping.

Sample configuration

Setup

The following snippet shows how to setup the browser console logger by registering it for dependency injection in the Startup.cs of the application.

public void ConfigureServices(IServiceCollection services)
{
    services.AddLogging(builder => builder
        .AddBrowserConsole() // Add Blazor.Extensions.Logging.BrowserConsoleLogger
        .SetMinimumLevel(LogLevel.Trace)
    );
}

Usage

The following snippet shows how to consume the logger in a Blazor component.

@inject ILogger<Index> logger

@functions {
  protected override async Task OnInitAsync()
  {
      logger.LogDebug("MyComponent init");
  }
}

If you want to consume it outside of a cshtml based component, then you can use the Inject attribute to inject it into the class.

[Inject]
protected ILogger<MyClass> Logger {get;set;}

public void LogSomething()
{
  Logger.LogDebug("Inside LogSomething");
}

Contributions and feedback

Please feel free to use the component, open issues, fix bugs or provide feedback.

Contributors

The following people are the maintainers of the Blazor Extensions projects:

Version History

Version Downloads Last updated
0.1.11 343 5/1/2019
0.1.10 2,249 11/26/2018
0.1.9 679 10/14/2018
0.1.8 964 7/28/2018
0.1.7 254 7/26/2018
0.1.6 150 7/26/2018
0.1.5 149 7/26/2018
0.1.4 150 7/26/2018
0.1.3 151 7/26/2018
0.1.2 452 6/8/2018
0.1.1 723 5/7/2018