log #12

Merged
rayhan.hassou merged 1 commits from log into master 2 years ago

@ -12,27 +12,4 @@
<br />
<AuthorizeView>
<Authorized>
<h1>Hello @context.User.Identity.Name !!</h1>
<p>Welcome to Blazor Learner.</p>
<ul>
@foreach (var claim in context.User.Claims)
{
<li>@claim.Type: @claim.Value</li>
}
</ul>
</Authorized>
<Authorizing>
<h1>Loading ...</h1>
</Authorizing>
<NotAuthorized>
<h1>Echec de la connexion!</h1>
<p>Vous n'etes pas connecté</p>
</NotAuthorized>
</AuthorizeView>
<SurveyPrompt Title="How is Blazor working for you?" />
<button @onclick="CreateLogs">Create logs</button>

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using CraftSharp.Models;
using Microsoft.Extensions.Logging;
namespace CraftSharp.Pages
{
@ -9,5 +10,18 @@ namespace CraftSharp.Pages
[Inject]
public IStringLocalizer<Index> Localizer { get; set; }
[Inject]
public ILogger<Index> Logger { get; set; }
private void CreateLogs()
{
var logLevels = Enum.GetValues(typeof(LogLevel)).Cast<LogLevel>();
foreach (var logLevel in logLevels.Where(l => l != LogLevel.None))
{
Logger.Log(logLevel, $"Log message for the level: {logLevel}");
}
}
}
}

@ -33,6 +33,7 @@ builder.Services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; });
builder.Services.AddHttpClient();
builder.Services.AddBlazoredModal();
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
builder.Services
.AddBlazorise()

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Loading…
Cancel
Save