Skip to content

EzrealJ/Extensions

Repository files navigation

1、Ezreal.Extension.AspNetCoreHttpLogging

Import

//in aspnetcore project StartUp.cs
        public void ConfigureServices(IServiceCollection services)
        {
            //...other TODO
            //Configuration is IConfiguration
        services.AddEzrealHttpLogging(Configuration.GetSection("ConfigurationSectionName"), option =>
            {
                option.ModuleName = nameof(AspNetCoreWebApp);
                option.SegmentedString = new string('-', 48);
            });
        }

Use

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            //...other TODO
            //Please pay attention to the reasonable arrangement of the pipeline sequence
            app.UseEzrealHttpLogging();
            app.UseRouting();
            //...other TODO
        }

Config

//for example
//in appsettings.json
{
  "Logging": {
    "LogLevel": {
      "Ezreal.Extension.AspNetCoreHttpLogging": "Information"
    }
  },
  "EzrealHttpLogging": {
    "ReadBody": true,
    "IgnoreWhenNoError": false,
     //logging if Ezreal.Extension.AspNetCoreHttpLogging LogLevel Enable this LogLevel
    "LogLevel": "Information" 
  }
}

About

.NET 扩展库,只包含扩展

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages