1

How does Serilog implemented period for capped collection? See this code:

Log.Logger = new LoggerConfiguration() .WriteTo.MongoDBCapped(
                            database: database,
                            restrictedToMinimumLevel: (Serilog.Events.LogEventLevel)logEventLevel,
                            collectionName: _collectionName,
                            period: TimeSpan.FromDays(RetainedDays))

Because according to the MongoDB documentation you can not store a document using its "TTL functionality" together with capped collection. So I am assuming: The library keeps somehow track of this inside its code, but I am wondering how: And if it is fast enough.

MongoDB Capped Collection: https://docs.mongodb.org/manual/core/capped-collections/ GitHub MongoDB Sink (target) for Serilog: https://github.com/serilog/serilog-sinks-mongodb

Maybe it would be even easy to write our own Sink with a normal collection together with TTL documents.

Matthias
  • 1,386
  • 3
  • 24
  • 59

1 Answers1

1

The period argument is not the TTL, but instead the duration for which Serilog will buffer events before sending them in a batch to MongoDB. I don't think TTL is supported through this API.

Nicholas Blumhardt
  • 30,271
  • 4
  • 90
  • 101