MongoDB with Serilog not working

My application maintains logs in MongoDB through Serilog and it was working great so far.

Recently, MondoDB server was moved to a different server for our DEV environment. Post this, the following tasks were performed at our end:

  • All the developers’ IP addresses were whitelisted for connectivity and we are able to read/write using Compass client.

  • Our application’s web configurations were updated with the new connectionstring

However, logging from our application in DEV (Visual studio) environment has stopped. Any attempt to check for possible cause has lead us nowhere.

Please suggest what could be the issue and if I should get in touch with our networking people for this.

What errors are being thrown by your dev app and in mongodb log file?

That’s the issue, serilog doesn’t throw any error which is making it difficult to pinpoint the root cause.

I just enabled debugging/diagnostics for Serilog and below is the generated exception:

2023-09-04T07:08:46.0982059Z Exception while emitting periodic batch from Serilog.Sinks.MongoDB.MongoDBSink: System.AggregateException: One or more errors occurred. —> MongoDB.Driver.MongoCommandException: Command insert failed: Unsupported OP_QUERY command: insert. The client driver may require an upgrade. For more details see

I guess this is due to version incompatibility between the MongoDB sink and the server. For now, I’ve asked IT team to install the server version which worked before.