title: Convert string into MongoDB BsonDocument (sequel)
body: <p>I have some problems converting JSON.NET generated json string to BsonDocument using the method that is suggested here: <a href="https://stackoverflow.com/questions/5624934/convert-string-into-mongodb-bsondocument">Convert string into MongoDB BsonDocument</a>. I am bulding a MongoDbLog4net appender which inserts LogMessages againt the mongodb. Those messages can contain exceptions and in some cases the exception object serializes to json string that contains points '.' in some keys causing the BsonSerializer.Desrialize method to complain. Is there an easy/efficient way to tell JsonConvert to not put or replace invalid characters with something else?</p>
  
  <pre><code>    protected override void Append(LoggingEvent loggingEvent)
      {
          // the log message here is used to filter and collect the
          // fields from loggingEvent we are interested in
          var logMessage = new LogMessage(loggingEvent);
  
          // since mongodb does not serialize exceptions very well we
          // will use JSON.NET to serialize the LogMessage instance
          // and build the BSON document from it
          string jsonLogMessage = JsonConvert.SerializeObject(logMessage);
  
          var bsonLogMessage = BsonSerializer.Deserialize&lt;BsonDocument&gt;(jsonLogMessage);
  
          this.logCollection.Insert(bsonLogMessage);
      }
  </code></pre>