Serilog.Enrichers.Claims
1.1.1-rc.1
This is a prerelease version of Serilog.Enrichers.Claims.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Serilog.Enrichers.Claims --version 1.1.1-rc.1
NuGet\Install-Package Serilog.Enrichers.Claims -Version 1.1.1-rc.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="Serilog.Enrichers.Claims" Version="1.1.1-rc.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Enrichers.Claims --version 1.1.1-rc.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Serilog.Enrichers.Claims, 1.1.1-rc.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.
// Install Serilog.Enrichers.Claims as a Cake Addin #addin nuget:?package=Serilog.Enrichers.Claims&version=1.1.1-rc.1&prerelease // Install Serilog.Enrichers.Claims as a Cake Tool #tool nuget:?package=Serilog.Enrichers.Claims&version=1.1.1-rc.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Serilog.Enrichers.AzureClaims
Enriches Serilog events with information from the ClaimsPrincipal.
Install the Serilog.Enrichers.AzureClaims NuGet package
Install-Package Serilog.Enrichers.AzureClaims
Then, apply the enricher to your LoggerConfiguration
:
Log.Logger = new LoggerConfiguration()
.Enrich.WithUpn()
.Enrich.WithDisplayName()
.Enrich.WithTenantId()
.Enrich.WithObjectId()
.Enrich.WithAppId()
// ...other configuration...
.CreateLogger();
Included enrichers
The package includes:
WithUpn()
- addsUserPrincipalName
based on the ClaimTypehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn
WithDisplayName()
- addsDisplayName
based on the ClaimTypehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
orname
orpreferred_username
WithTenantId()
- addsTenantId
based on the ClaimTypehttp://schemas.microsoft.com/identity/claims/tenantid
ortid
WithObjectId()
- addsObjectId
based on the ClaimTypehttp://schemas.microsoft.com/identity/claims/objectidentifier
oroid
WithAppId
- addsAppId
based on the CLaimTypeappid
orazp
Installing into an ASP.NET Core Web Application
You need to register the IHttpContextAccessor
singleton so the enrichers have access to the requests HttpContext
to extract the data.
This is what your Program
class should contain in order for this enricher to work as expected:
// ...
using Serilog;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddSerilog(new LoggerConfiguration()
.Enrich.WithUpn()
.Enrich.WithDisplayName()
.Enrich.WithTenantId()
.Enrich.WithObjectId()
.Enrich.WithAppId()
.CreateLogger());
// ...
builder.Services.AddHttpContextAccessor();
// ...
var app = builder.Build();
app.UseSerilogRequestLogging();
// ...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Identity.Web (>= 3.4.0)
- Serilog (>= 4.1.0)
-
net7.0
- Microsoft.Identity.Web (>= 3.4.0)
- Serilog (>= 4.1.0)
-
net8.0
- Microsoft.Identity.Web (>= 3.4.0)
- Serilog (>= 4.1.0)
-
net9.0
- Microsoft.Identity.Web (>= 3.4.0)
- Serilog (>= 4.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.1 | 853 | 11/22/2024 |
1.1.1-rc.2 | 58 | 11/22/2024 |
1.1.1-rc.1 | 60 | 11/22/2024 |