Skip to content

improve logging context by adding authenticated user information #14

@https-richardy

Description

@https-richardy

The request pipeline already includes a CorrelationMiddleware responsible for generating and propagating the CorrelationId, enriching both the logging context and the Sentry scope to enable full request traceability in production.

However, logs currently do not include information about the authenticated user when a request requires authentication. This makes it harder to investigate issues related to specific user actions, such as permission errors, data inconsistencies, or failures during sensitive operations.

The proposed improvement is to enrich the logging context inside the PrincipalMiddleware by adding properties related to the authenticated user, such as user_id and optionally user_name. These properties should be added both to the Serilog LogContext and to the Sentry scope.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions