Logly 3.0.1
dotnet add package Logly --version 3.0.1
NuGet\Install-Package Logly -Version 3.0.1
<PackageReference Include="Logly" Version="3.0.1" />
<PackageVersion Include="Logly" Version="3.0.1" />
<PackageReference Include="Logly" />
paket add Logly --version 3.0.1
#r "nuget: Logly, 3.0.1"
#:package Logly@3.0.1
#addin nuget:?package=Logly&version=3.0.1
#tool nuget:?package=Logly&version=3.0.1
Logly
Logly is an ASP.NET Core middleware library for structured HTTP request and response logging. It is inspired by morgan for Node.js and gives you control over exactly what gets logged, with minimal setup.
Example Output
Installation
Install via the NuGet package manager:
dotnet add package Logly
Or via the Package Manager Console:
Install-Package Logly
Supported Frameworks
- .NET Core 3.1
- .NET 5, 6, 7, 8, 9, 10
Prerequisites
To avoid duplicate log output, clear the default ASP.NET Core logging providers when building your host:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((context, logging) =>
{
logging.ClearProviders();
})
.UseStartup<Startup>()
.Build();
Setup
Simple Setup
Add a single line to your middleware pipeline in Program.cs or Startup.cs:
app.UseLogly();
This logs the following by default:
- HTTP method (GET, POST, etc.)
- Request URL
- Response status code
Custom Setup
Use LoggerOptionsBuilder to choose exactly what gets logged:
app.UseLogly(opts => opts
.AddRequestMethod() // HTTP method (GET, POST, etc.)
.AddUrl() // Request URL
.AddStatusCode() // Response status code
.AddResponseTime() // Time taken to process the request (ms)
.AddResponseLength() // Response body size (bytes)
);
Ignoring URLs
Use IgnoreUrls to exclude specific paths from logging. This is useful for health checks, metrics endpoints, or any route you do not want to appear in logs.
app.UseLogly(opts => opts
.AddRequestMethod()
.AddStatusCode()
.IgnoreUrls("/health", "/metrics", "/swagger/*")
);
Glob patterns are supported, so /swagger/* will match all routes under /swagger/.
Credits
This library was originally based on work by Casey MacPherson.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
-
net10.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
-
net5.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
-
net6.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
-
net7.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
-
net9.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- update dependencies
- add newer .NET version support
- remove older targets like ASP.NET 1 and 2