ILogger implementation that returns streaming logs via an HTTP endpoint
<ItemGroup>
<PackageReference Include="Shirhatti.WebLogger" Version="x" />
</ItemGroup>
or
dotnet add package Shirhatti.WebLogger
- Update
Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
+ .ConfigureLogging(logging =>
+ {
+ logging.AddWebLogger();
+ })
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
- Update
Startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
+ if (env.IsDevelopment())
+ {
+ endpoints.MapLogs();
+ }
});
}
-
Change desired log level settings in
appSettings.Development.json
-
Run your application-
dotnet run
-
Navigate to
https://localhost:5001/debug/logs
to view your streaming logs
Incomplete docs at https://shirhatti.com/Shirhatti.WebLogger/