Home

Awesome

Serilog.Sinks.SQLite.Maui

The fork of Serilog.Sinks.SQLite

Referring to this issue https://github.com/saleem-mirza/serilog-sinks-sqlite/issues/24#issuecomment-608555305

It can run normally in Maui

I made the following changes

//if (!sqliteDbPathUri.IsAbsoluteUri) {
//    var basePath = System.Reflection.Assembly.GetEntryAssembly().Location;
//    sqliteDbPath = Path.Combine(Path.GetDirectoryName(basePath) ?? throw new NullReferenceException(), sqliteDbPath);
//}

Getting started

Install Serilog.Sinks.SQLite.Maui from NuGet

Install-Package Serilog.Sinks.SQLite.Maui

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");