LogStream.AspNetCore
1.0.1
dotnet add package LogStream.AspNetCore --version 1.0.1
NuGet\Install-Package LogStream.AspNetCore -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LogStream.AspNetCore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogStream.AspNetCore" Version="1.0.1" />
<PackageReference Include="LogStream.AspNetCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LogStream.AspNetCore --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LogStream.AspNetCore, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LogStream.AspNetCore@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LogStream.AspNetCore&version=1.0.1
#tool nuget:?package=LogStream.AspNetCore&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LogStream.AspNetCore
dotnet add package LogStream.AspNetCore
Middleware ASP.NET Core que regista cada pedido HTTP como dois eventos Serilog, request e response, com o
mesmo TraceId W3C e o mesmo SessionId. No LogStream, o pedido, os logs internos da app e a resposta aparecem juntos
numa só timeline.
Os eventos seguem pelo Serilog. Para os enviar para o Kafka do LogStream, use também o pacote LogStream.Serilog.Kafka.
Uso
builder.Services.AddLogStreamHttpLogging(o =>
{
o.MaxBodyBytes = 16 * 1024; // limite dos bodies registados (omissão 32 KB)
o.MaskedJsonFields.Add("nif"); // campos JSON a mascarar, além dos de omissão
});
var app = builder.Build();
app.UseAuthentication();
app.UseLogStreamHttpLogging(); // depois da autenticação (para saber o utilizador), antes dos endpoints
app.MapControllers();
O que regista
- Método, caminho, query, status e duração.
- Headers, com
Authorization,Cookie,Set-Cookie,X-Api-KeyeProxy-Authorizationmascarados. - Bodies de texto ou JSON até
MaxBodyBytes. Os campos sensíveis (password,token,secret,apiKey,iban, …) ficam com***, em qualquer nível do JSON. - SessionId: vem do header
X-Session-Id; se não existir, deSessionCookie; se também não existir, do claimsid. - TraceId: é devolvido ao cliente no header
X-Trace-Id. - Nível do evento: 4xx = Warning, 5xx = Error (
LevelByStatusCode). - Caminhos ignorados:
/health,/healthz,/metrics,/favicon.icoe/swagger(ExcludePaths).
O mascaramento acontece na própria aplicação, por isso os dados sensíveis nunca chegam ao Kafka.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Serilog (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.