Majorsoft.Blazor.WebAssembly.Logging.Console
1.6.1
dotnet add package Majorsoft.Blazor.WebAssembly.Logging.Console --version 1.6.1
NuGet\Install-Package Majorsoft.Blazor.WebAssembly.Logging.Console -Version 1.6.1
<PackageReference Include="Majorsoft.Blazor.WebAssembly.Logging.Console" Version="1.6.1" />
<PackageVersion Include="Majorsoft.Blazor.WebAssembly.Logging.Console" Version="1.6.1" />
<PackageReference Include="Majorsoft.Blazor.WebAssembly.Logging.Console" />
paket add Majorsoft.Blazor.WebAssembly.Logging.Console --version 1.6.1
#r "nuget: Majorsoft.Blazor.WebAssembly.Logging.Console, 1.6.1"
#:package Majorsoft.Blazor.WebAssembly.Logging.Console@1.6.1
#addin nuget:?package=Majorsoft.Blazor.WebAssembly.Logging.Console&version=1.6.1
#tool nuget:?package=Majorsoft.Blazor.WebAssembly.Logging.Console&version=1.6.1
Blazor WebAssembly Hosted model console logging
About
Blazor extension for logging to browser console. Important NOTE: this package only works for apps using WebAssemly Hosting Model!
You can try it out by using the demo app.
NOTE: in .NET 5 WebAssembly Apps will log to browser's console automatically. This package uses Console.WriteLine()
non JS based logging. So all log level messages will shown regardless of browser log filter.
Features
Logger
This package implements Microsoft Extensions Logging abstraction to
support using of ILogger and ILogger<T> interface for WebAssemly Blazor Console logging.
When this package installed and configured all logs written by ILogger and ILogger<T> will reach
Browser console logger and log messages will appear in the browser's developer tools Console tab.
Log levels
The logger supports the LogLevels defined by Microsoft LogLevel enum.
Configuration
Installation
Majorsoft.Blazor.Components.Deboudnce.Input is available on NuGet.
dotnet add package Majorsoft.Blazor.WebAssembly.Logging.Console
Use the --version option to specify a preview version to install.
Setup
Add the following code snippet to your WebAssembly hosted (client side) Blazor Application.
Into the **Program.cs** file 'Main' method.
using Majorsoft.Blazor.WebAssembly.Logging.Console;
...
builder.Logging.AddBrowserConsole()
.SetMinimumLevel(LogLevel.Debug) //Setting LogLevel is optional
.AddFilter("Microsoft", LogLevel.Information); //System logs can be filtered.
Usage
After setup usage is very simple. Just use by standard logging with injected ILogger object. The following code snippet shows how to use logger in a Blazor component.
@using Microsoft.Extensions.Logging
@inject ILogger<Index> _logger
@code {
protected override void OnInitialized()
{
_logger.LogDebug("Index init");
}
}
The following code snippet shows how to use logger in .cs files.
using Microsoft.Extensions.Logging;
...
public class CustomCode
{
private readonly ILogger<CustomCode> _logger;
public CustomCode(ILogger<CustomCode> logger)
{
_logger = logger;
_logger.LogDebug("CustomCode init");
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net5.0
- Microsoft.AspNetCore.Components.Web (>= 5.0.3)
- Microsoft.Extensions.Logging (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See Releases here: https://github.com/majorimi/blazor-components/releases