Skip to content

Commit de25231

Browse files
committed
Update the README and the CHANGELOG for the new UseNullText feature
1 parent 1b6c0c5 commit de25231

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.4.0][1.4.0] - 2025-09-19
8+
9+
- Properties whose values are `null` are now always serialized with a `value` attribute. Thanks to @southernprogrammer for reporting this issue. See the [Null text](https://github.com/serilog-contrib/serilog-formatting-log4net#null-text) documentation in the README for more information.
10+
11+
Before (1.3.1)
12+
13+
```xml
14+
<log4net:properties>
15+
<log4net:data name="key" />
16+
</log4net:properties>
17+
```
18+
19+
After (1.4.0)
20+
21+
```xml
22+
<log4net:properties>
23+
<log4net:data name="key" value="(null)" />
24+
</log4net:properties>
25+
```
26+
727
## [1.3.1][1.3.1] - 2025-04-30
828

929
- Log events coming from `Microsoft.Extensions.Logging` are now identified if they have **either** an `EventId.Id` or an `EventId.Name` property. Previously, log events coming from `Microsoft.Extensions.Logging` were identified if they had **both** an `Id` and a `Name` property.
@@ -139,7 +159,8 @@ Still trying to figure out how to make everything fit together with [MinVer](htt
139159

140160
- Implement log4j compatibility mode.
141161

142-
[Unreleased]: https://github.com/serilog-contrib/serilog-formatting-log4net/compare/1.3.1...HEAD
162+
[Unreleased]: https://github.com/serilog-contrib/serilog-formatting-log4net/compare/1.4.0...HEAD
163+
[1.4.0]: https://github.com/serilog-contrib/serilog-formatting-log4net/compare/1.3.1...1.4.0
143164
[1.3.1]: https://github.com/serilog-contrib/serilog-formatting-log4net/compare/1.3.0...1.3.1
144165
[1.3.0]: https://github.com/serilog-contrib/serilog-formatting-log4net/compare/1.2.0...1.3.0
145166
[1.2.0]: https://github.com/serilog-contrib/serilog-formatting-log4net/compare/1.1.0...1.2.0

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,28 @@ By default, Log4NetTextFormatter writes all messages and exceptions with a [CDAT
106106
new Log4NetTextFormatter(c => c.UseCDataMode(CDataMode.Never))
107107
```
108108

109+
### Null text
110+
111+
Available since version 1.4.0
112+
113+
By default, when a property value is `null`, the text used for its representation is `(null)`. This can be changed with the `UseNullText()` configuration method.
114+
115+
Here's how to configure the formatter to use `🔷null🔷` when a property value is `null`.
116+
117+
```c#
118+
new Log4NetTextFormatter(c => c.UseNullText("🔷null🔷"));
119+
```
120+
121+
This will produce the following output.
122+
123+
```xml
124+
<log4net:properties>
125+
<log4net:data name="key" value="🔷null🔷" />
126+
</log4net:properties>
127+
```
128+
129+
To restore compatibility with version 1.3.1 and earlier (which produced a non-compatible XML), `UseNullText(null)` can be called.
130+
109131
### XML Namespace
110132

111133
You can remove the `log4net` XML namespace by calling `UseNoXmlNamespace()` on the options builder. This is useful if you want to spare some bytes and your log reader supports log4net XML events without namespace, like [Log4View](https://www.log4view.com) does.

0 commit comments

Comments
 (0)