Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Completed
Created by Guest
Created on Oct 22, 2024

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.
  • Guest
    Nov 13, 2024
    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-docs On the driver side, our specifications for all drivers require to raise the errors that are coming for the server. .NET driver follows this requirement.