NLog.Mongo icon indicating copy to clipboard operation
NLog.Mongo copied to clipboard

关于this.AddProperties(bsonDocument, logEvent);内部方法问题

Open wheeky opened this issue 6 years ago • 0 comments

private BsonDocument CreateDocument(LogEventInfo logEvent) { BsonDocument bsonDocument = new BsonDocument(); if (this.IncludeDefaults || this.Fields.Count == 0) { this.AddDefaults(bsonDocument, logEvent); } foreach (MongoField current in this.Fields) { BsonValue value = this.GetValue(current, logEvent); if (value != null) { bsonDocument.set_Item(current.Name, value); } } this.AddProperties(bsonDocument, logEvent); return bsonDocument; } 这个方法能否设为虚方法,以便通过继承重写满足不同的插入到MONGO DB的字段格式,目前当我想把自定义字段加入到mongoDB中时,发现this.AddProperties(bsonDocument, logEvent);会把mongoTarget.Properties与eventInfo.Properties的字段都插入到mongoDB中,eventInfo.Properties存在于mongoDB的Properties键对面对应的字段,如果想输出自定义字段,那么则会造成mongoDB中的字段与Properties键对面对应的字段存在重复字段的情况,需要改善

wheeky avatar Nov 18 '17 07:11 wheeky