Last week a collegae mentionted he had some problems with Serilog, a structured logging library for .NET. Most of the time it just worked fine, but he noticed that in some situations no log messages were written to a sink. We first thought it had something to do with misconfigured log levels but that turned out to be a wrong assumption.
In the end, we found the root cause after enabling the Serilog debug log:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serilog.Debugging.SelfLog.Enable(message => { | |
Debug.WriteLine(message); | |
}); |
After doing that, we discovered that in some cases the following message was logged:
Maximum destructuring depth reached.
Due to a recursive object in one of our log messages, the JSON serializer gives up and Serilog discards the message.