public IMongoDatabase GetDatabase()
        {
            if (string.IsNullOrWhiteSpace(ConnectionString))
            {
                return(BackwardCompatibility.GetDatabase(this));
            }
            var mongoUrl = MongoUrl.Create(ConnectionString);
            var client   = new MongoClient(mongoUrl);
            var db       = client.GetDatabase(mongoUrl.DatabaseName ?? "log4net");

            return(db);
        }
        private BsonDocument BuildBsonDocument(LoggingEvent log)
        {
            if (_fields.Count == 0)
            {
                return(BackwardCompatibility.BuildBsonDocument(log));
            }
            var doc = new BsonDocument();

            foreach (MongoAppenderFileld field in _fields)
            {
                object    value     = field.Layout.Format(log);
                BsonValue bsonValue = BsonValue.Create(value);
                doc.Add(field.Name, bsonValue);
            }
            return(doc);
        }