Skip to content

Commit 0606473

Browse files
Bump version to 2.0.0
1 parent 57e4029 commit 0606473

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog for Serilog.Enrichers.Sensitive
22

3+
## 2.0.0
4+
5+
This release introduces support for configuring `MaskProperties` via JSON. As the version number indicates this is a breaking change as the C# equivalent had to be changed to match.
6+
See the [README](README.md) for more details on configuring specific property masking options.
7+
38
## 1.7.4
49

510
- Add masking options for properties [#29](https://github.com/serilog-contrib/Serilog.Enrichers.Sensitive/issues/29)

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>1.7.4.0</Version>
3+
<Version>2.0.0.0</Version>
44
<Authors>Sander van Vliet, Huibert Jan Nieuwkamer, Scott Toberman</Authors>
55
<Company>Codenizer BV</Company>
6-
<Copyright>2023 Sander van Vliet</Copyright>
6+
<Copyright>2025 Sander van Vliet</Copyright>
77
</PropertyGroup>
88
</Project>

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,66 @@ An example config file:
318318
```
319319

320320
> **Warning:** Contrary to what you might expect, for JSON configuration `Operators` should be used instead of `MaskingOperators`.
321+
322+
### Masking specific properties
323+
324+
You can configure specific options for property masking via the `MaskProperties` property via code as well as JSON.
325+
326+
From code:
327+
328+
```csharp
329+
var logger = new LoggerConfiguration()
330+
.Enrich.WithSensitiveDataMasking(options =>
331+
{
332+
options.MaskProperties.Add(MaskProperty.WithDefaults("Email"));
333+
})
334+
.WriteTo.Sink(inMemorySink)
335+
.CreateLogger();
336+
```
337+
338+
Here we're using `MaskProperty.WithDefaults()` to indicate we just want to mask the `Email` property. You can specify more options like so:
339+
340+
```csharp
341+
var logger = new LoggerConfiguration()
342+
.Enrich.WithSensitiveDataMasking(options =>
343+
{
344+
options.MaskProperties.Add(new MaskProperty
345+
{
346+
Name = "Email",
347+
Options = new MaskOptions {
348+
ShowFirst = 3
349+
}
350+
});
351+
})
352+
.WriteTo.Sink(inMemorySink)
353+
.CreateLogger();
354+
```
355+
356+
Via JSON configuration (for example `appsettings.json`) you can follow a similar approach:
357+
358+
```json
359+
{
360+
"Serilog": {
361+
"Using": [
362+
"Serilog.Enrichers.Sensitive"
363+
],
364+
"Enrich": [
365+
{
366+
"Name": "WithSensitiveDataMasking",
367+
"Args": {
368+
"options": {
369+
"MaskProperties": [
370+
{
371+
"Name": "someproperty",
372+
"Options": {
373+
"ShowFirst": 3
374+
}
375+
}
376+
]
377+
}
378+
}
379+
}
380+
]
381+
}
382+
}
383+
```

0 commit comments

Comments
 (0)