A simple to use sink for Serilog that saves logs in a Mongodb time series collection.
Explore the docs »
Report Bug
·
Request Feature
Serilog.Sinks.Mongodb.TimeSeries is a nuget package to save all your logs to a time series mongodb collection.
It is super simple to setup! There are only a couple lines needed. Head down to the Installation guide for more info.
To get a local copy up and running follow these simple steps.
Serilog.Sinks.Mongodb.TimeSeries is available on NuGet.
-
Serilog.Sinks.Mongodb.TimeSeries
Install-Package Serilog.Sinks.Mongodb.TimeSeries
OR
dotnet add package Serilog.Sinks.Mongodb.TimeSeries
- Clone the repo
git clone https://github.com/BrammyS/Serilog.Sinks.Mongodb.TimeSeries.git
- Build the repo
dotnet build
You will need to do the following to add Serilog.Sinks.Mongodb.TimeSeries as a sink in your program.
var client = new MongoClient("mongodb://mongodb0.example.com:27017");
var mongoDatabase = client.GetDatabase("dbName");
Log.Logger = new LoggerConfiguration()
.WriteTo.MongoDbTimeSeriesSink(mongoDatabase)
.CreateLogger();
var client = new MongoClient("mongodb://mongodb0.example.com:27017");
var mongoDatabase = client.GetDatabase("dbName");
var configs = new MongoDbTimeSeriesSinkConfig(mongoDatabase)
{
CollectionName = "Logs",
TimeSeriesGranularity = TimeSeriesGranularity.Seconds,
SyncingPeriod = TimeSpan.FromSeconds(10),
LogsExpireAfter = TimeSpan.FromDays(7),
MaxCollectionSize = 100 * 1024 * 1024,
EagerlyEmitFirstEvent = true,
MaxLogsAmount = 100000,
BatchSizeLimit = 500,
QueueLimit = 20000
};
Log.Logger = new LoggerConfiguration()
.WriteTo.MongoDbTimeSeriesSink(configs)
.CreateLogger();
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Serilog.Sinks.Mongodb.TimeSeries uses Semantic Versioning 2.0.0 for its versioning.
The versioning will be using the following format: MAJOR.MINOR.PATCH.
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards compatible manner, and
- PATCH version when you make backwards compatible bug fixes.
- Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Distributed under the MIT License. See LICENSE
for more information.