NLog 没有将空的自定义事件属性写入 Sql 数据库

NLog isn't writing an empty custom event propperties into SqlDatabase

我的配置中有一些自定义事件布局,如下所示{event-properties:item=SomeCustomProperty}

像这样填写它们:

var testLogger = testNLogFactory.GetLogger("Test");
LogEventInfo theEvent = new LogEventInfo(LogLevel.Debug, null, "Test");
theEvent.Properties.Add("SomeCustomProperty", null);
testLogger.Debug(theEvent);

我有两个目标,文件和数据库。文件目标工作正常,但在数据库的情况下,只要 SomeCustomProperty 值保持为空,就不会写入此记录。如果我用任何值替换 null,它就可以正常工作。

数据库中对应的 table 是正确的,允许 SomeCustomProperty 中的 NULL 值,但如果 {event-properties:item=SomeCustomProperty} 没有值,则不会将记录添加到数据库。

这种行为有什么原因吗?有什么解决方法吗?

所有布局渲染器,如 ${event-properties:item=SomeCustomProperty},如果为空,将 return 一个空字符串,而不是 null