Skip to content

ILogger implementation that returns streaming logs via an HTTP endpoint

License

Notifications You must be signed in to change notification settings

shirhatti/Shirhatti.WebLogger

Repository files navigation

Shirhatti.WebLogger

ILogger implementation that returns streaming logs via an HTTP endpoint

weblogger

Usage

  1. Add package reference version
  <ItemGroup>
    <PackageReference Include="Shirhatti.WebLogger" Version="x" />
  </ItemGroup>

or

dotnet add package Shirhatti.WebLogger
  1. Update Program.cs
        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
+                .ConfigureLogging(logging =>
+                {
+                    logging.AddWebLogger();
+                })
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
  1. 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();
+                }
            });
        }
  1. Change desired log level settings in appSettings.Development.json

  2. Run your application- dotnet run

  3. Navigate to https://localhost:5001/debug/logs to view your streaming logs

Docs

Incomplete docs at https://shirhatti.com/Shirhatti.WebLogger/

About

ILogger implementation that returns streaming logs via an HTTP endpoint

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages