using Microsoft.AspNetCore.Components; namespace Expose.MyIT.Client.Pages; public partial class Counter { [Inject] protected ILogger? Logger { get; set; } private int _CurrentCount = 0; private void IncrementCount() { if (Logger is null) throw new NullReferenceException(nameof(Logger)); Logger.LogWarning("Someone has clicked me!"); _CurrentCount++; } }