Serilog:是时候生活在 mongoDB Capped Collection 中了吗?

Serilog: Time to Live in mongoDB Capped Collection?

Serilog 是如何实现 capped collection 的周期的?请参阅此代码:

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

因为根据 MongoDB 文档,您不能将其 "TTL functionality" 与上限集合一起使用来存储文档。所以我假设:图书馆以某种方式在其代码中跟踪这一点,但我想知道如何:如果它足够快。

MongoDB 上限集合:https://docs.mongodb.org/manual/core/capped-collections/ GitHub MongoDB Serilog 的接收器(目标):https://github.com/serilog/serilog-sinks-mongodb

也许用普通集合和 TTL 文档编写我们自己的 Sink 会更容易。

period 参数不是 TTL,而是 Serilog 在将事件批量发送到 MongoDB 之前缓冲事件的持续时间。我认为 API.

不支持 TTL