下载源代码并在 MongoDB LoggerConfiguration 类构造函数的签名中添加一个集合参数。更改后的代码标有**。
public static LoggerConfiguration MongoDB(
this LoggerSinkConfiguration loggerConfiguration,
string databaseUrl,
**string collectionName = null,**
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
int batchPostingLimit = MongoDBSink.DefaultBatchPostingLimit,
TimeSpan? period = null,
IFormatProvider formatProvider = null)
{
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
if (databaseUrl == null) throw new ArgumentNullException("databaseUrl");
var defaultedPeriod = period ?? MongoDBSink.DefaultPeriod;
return loggerConfiguration.Sink(
new MongoDBSink(
databaseUrl,
batchPostingLimit,
defaultedPeriod,
formatProvider,
**collectionName ??** MongoDBSink.DefaultCollectionName,
new CreateCollectionOptions()),
restrictedToMinimumLevel);
}