Skip to content

omarbekov/serilog-sinks-sqlite

 
 

Repository files navigation

Serilog.Sinks.SQLite

A lightweight high performance Serilog sink that writes to SQLite database.

Getting started

Install Serilog.Sinks.SQLite from NuGet

Install-Package Serilog.Sinks.SQLite

Configure logger by calling WriteTo.SQLite()

var logger = new LoggerConfiguration()
    .WriteTo.SQLite(@"Logs\log.db")
    .CreateLogger();
    
logger.Information("This informational message will be written to SQLite database");

XML configuration

To use the SQLite sink with the Serilog.Settings.AppSettings package, first install that package if you haven't already done so:

Install-Package Serilog.Settings.AppSettings

In your code, call ReadFrom.AppSettings()

var logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

In your application's App.config or Web.config file, specify the SQLite sink assembly and required sqliteDbPath under the <appSettings> node:

<appSettings>
    <add key="serilog:using:SQLite" value="Serilog.Sinks.SQLite"/>
    <add key="serilog:write-to:SQLite.sqliteDbPath" value="Logs\log.db"/>
    <add key="serilog:write-to:SQLite.tableName" value="Logs"/>
    <add key="serilog:write-to:SQLite.storeTimestampInUtc" value="true"/>
</appSettings>    

Performance

SQLite sink automatically buffers log internally and flush to SQLite database in batches on dedicated thread.

Build status


Many thanks to the for donating awesome suite of tools making this project possible.

About

A Serilog sink that writes to SQLite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.0%
  • PowerShell 3.0%