Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support log property individually #124

Open
rickykiet83 opened this issue Oct 29, 2024 · 0 comments
Open

Support log property individually #124

rickykiet83 opened this issue Oct 29, 2024 · 0 comments
Assignees

Comments

@rickykiet83
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.

I have class like this:

public class Payment
{
public int PaymentId { get; set; }

public Guid UserId { get; set; }

public DateTime OccuredAt { get; set; }

[LogMasked]
public string Email { get; set; }

}

var payment = new Payment
{
PaymentId = 1,
UserId = Guid.NewGuid(),
Email = "[email protected]",
OccuredAt = DateTime.UtcNow
};

logger.Information("Received payment with details {@payment}", payment);
logger.Information("Received payment with details Payment Id: {PaymentId}, Email: {Email}", payment.PaymentId, payment.Email);

When using Destructurama.Attributed, the [LogMasked] attribute works only when logging the entire object as a structured property, like {@payment}. Unfortunately, if we log properties individually ({Email}), Serilog doesn’t apply the attribute-based masking by default.

Describe the solution you'd like
This is optional description of what you want to happen.
Create a custom attribute to indicate that field is masked as well, ensuring that sensitive fields are consistently masked regardless of how they’re logged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants