Reputation: 125
I have a few custom event layouts in my configuration like this {event-properties:item=SomeCustomProperty}
Filling them out like this:
var testLogger = testNLogFactory.GetLogger("Test");
LogEventInfo theEvent = new LogEventInfo(LogLevel.Debug, null, "Test");
theEvent.Properties.Add("SomeCustomProperty", null);
testLogger.Debug(theEvent);
I have 2 targets, file and database. File target works fine but in case of database this record won't be written as long as SomeCustomProperty value stays null. If I replace null
with any value, it works just fine.
The corresponding table in the database is correct and allows NULL
values in SomeCustomProperty
but if {event-properties:item=SomeCustomProperty}
has no value the record won't be added to the database.
Is there any reason for this behavior? Is there any workaround?
Upvotes: 0
Views: 167
Reputation: 36700
All layout renderers, like ${event-properties:item=SomeCustomProperty}
, will return an empty string if empty, and not null
Upvotes: 1