A Serilog sink that writes events as documents to RavenDB.
Package - Serilog.Sinks.RavenDB | Platforms - .NET Standard 2.0 (.NET 4.6.1 or later; .NET Core 2.0 or later)
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.
You can also configure the sink through your application config file using Serilog.Settings.AppSettings
Log.Logger = new LoggerConfiguration() .ReadFrom.AppSettings() .CreateLogger();
<connectionStrings> <add name="Logs" connectionString="Url=http://[RAVEN_DB_SERVER]:8080/;DefaultDatabase=[OPTIONAL_DEFAULT_DATABASE]" /> </connectionStrings> <appSettings> <add key="serilog:minimum-level" value="Information" /> <add key="serilog:using:RavenDB" value="Serilog.Sinks.RavenDB" /> <add key="serilog:write-to:RavenDB.connectionStringName" value="Logs" /> <add key="serilog:write-to:RavenDB.defaultDatabase" value="[DEFAULT_DATABASE]" /> </appSettings>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:
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.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.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4