Provide an event for collecting schema validation, with validation Action as a warning.
We are looking for a method for collecting data related to scheme validation issues for logging in the c# driver. Currently, we can set schema validation to error and capture the issue using mongo write exceptions. However, we don't want to restrict the data write, but rather capture the invalid document in the logs to determine the root cause.
-
Boris commented
Hi Kishore,
Enabling schema validation logging on the server side can be done in following way:
CreateCollectionOptions.ValidationAction = DocumentValidationAction.Warn;
(driver/3.0.0/api/MongoDB.Driver/MongoDB.Driver.CreateCollectionOptions.ValidationAction.html#MongoDB_Driver_CreateCollectionOptions_ValidationAction)Please find more documentation on this, and how to fetch the server logs here:
https://www.mongodb.com/docs/manual/core/schema-validation/handle-invalid-documents/#std-label-schema-validation-handle-invalid-docsOn the driver side, our specifications for all drivers require to raise the errors that are coming for the server. .NET driver follows this requirement.