ChangemakerStudios / serilog-sinks-mongodb

A sink for Serilog that writes events to MongoDB
Apache License 2.0
92 stars 53 forks source link

It's not possible to remove default properties #30

Closed pregoli closed 3 years ago

pregoli commented 7 years ago

It is not possible to avoid to write the "MessageTemplate" property. It s only possible to remove custom ones.

nblumhardt commented 7 years ago

One option to achieve this is by accepting a custom ITextFormatter to override the default formatter.

pregoli commented 7 years ago

Thanks for your reply but I'm talking about serilog-sinks-mongodb. If you take a look at the source code it's creating the bsonDocument from the logEvent object. There are no available params to ignore some properties.

nblumhardt commented 7 years ago

Ah, that's right - forgot MongoDB is BSON 👍 Thanks!

vibs2006 commented 3 years ago

can anyone help me in removing "MessageTemplate" property here? I'm not able to understand the resolution from comments image My simple 3 line code

 IMongoDatabase database = client.GetDatabase("log");
 Log.Logger = new LoggerConfiguration().WriteTo.MongoDB(database).CreateLogger();            
 Log.Information("This is test log {proper}",1);
Jaben commented 3 years ago

Please try the latest with the MongoDBBson() sink.

wuzhenda commented 2 years ago

I'm still confused. has it done?