with your project set to C# 10 (add <LangVersion>preview</LangVersion>
to your .csproj file), in your Program.cs simply add ILogger<Program> logger
to your endpoint delegate:
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;