Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ravendb/serilog-sinks-ravendb
A Serilog sink that writes events to RavenDB
https://github.com/ravendb/serilog-sinks-ravendb
ravendb serilog
Last synced: about 2 months ago
JSON representation
A Serilog sink that writes events to RavenDB
- Host: GitHub
- URL: https://github.com/ravendb/serilog-sinks-ravendb
- Owner: ravendb
- License: apache-2.0
- Created: 2015-02-22T22:54:26.000Z (over 9 years ago)
- Default Branch: dev
- Last Pushed: 2024-02-20T11:53:47.000Z (7 months ago)
- Last Synced: 2024-05-22T01:12:42.085Z (4 months ago)
- Topics: ravendb, serilog
- Language: C#
- Size: 75.2 KB
- Stars: 17
- Watchers: 5
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Serilog.Sinks.RavenDB
[![Build status](https://ci.appveyor.com/api/projects/status/maf8tidwq1xbvrqh/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-ravendb/branch/master) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.RavenDB.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.RavenDB/)
A [Serilog](https://serilog.net) sink that writes events as documents to [RavenDB](http://ravendb.net).
**Package** - [Serilog.Sinks.RavenDB](http://nuget.org/packages/serilog.sinks.ravendb)
| **Platforms** - .NET Standard 2.0 (.NET 4.6.1 or later; .NET Core 2.0 or later)```csharp
var logs = new DocumentStore { ConnectionStringName = "Logs" }.Initialize();var log = new LoggerConfiguration()
.WriteTo.RavenDB(logs)
.CreateLogger();
```You'll need to create a database on the server for logs, and specify this as your default database in the connection string or `DocumentStore.DefaultDatabase`. In the alternative, you can pass a default database when configuring the RavenDB sink. [More information](http://nblumhardt.com/2013/06/serilog-and-ravendb/).
You can also configure the sink through your application config file using [Serilog.Settings.AppSettings](https://www.nuget.org/packages/Serilog.Settings.AppSettings)
```csharp
Log.Logger = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();
```
```xml
```
### Automatic Log Record Expiration
If you install the RavenDB expiration bundle on the database where log records are stored, you can configure the
sink to automatically delete log records. There are two ways to do this:
* Simple version: passing `errorExpiration` (for fatal and error messages) and `expiration` (for all other messages). If you pass one, you should pass both. `Timeout.InfiniteTimeSpan` indicates that messages of the appropriate type will never be deleted by the expiration bundle.
* Featured version: passing `logExpirationCallback`, a which will receive a Serilog `LogEvent` and return a `TimeSpan`. `Timeout.InfiniteTimeSpan` indicates that the message will never be deleted by the expiration bundle.