swimlane / serilog-sinks-mongodb

A sink for Serilog that writes events to MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serilog.Sinks.MongoDB

Build status

A Serilog sink that writes events as documents to MongoDB.

Package - Serilog.Sinks.MongoDB | Platforms - .NET 4.6

You'll need to create a collection on your MongoDB server. In the example shown, the database in use is called logs. The collection name is log and is created implicitely.

var log = new LoggerConfiguration()
    .WriteTo.MongoDB("mongodb://mymongodb/logs")
    .CreateLogger();

Additionally you can utilize a Capped Collection. This type allows explicit collection naming.

var log = new LoggerConfiguration()
    .WriteTo.MongoDBCapped("mongodb://mymongodb/logs", collectionName: "customCollectionName")
    .CreateLogger();

About

A sink for Serilog that writes events to MongoDB

License:Apache License 2.0


Languages

Language:C# 91.8%Language:PowerShell 8.2%