Open HendrikKoelbel opened 4 years ago
LiteDB shared connection is supported by pass connectionString
, please look here: https://github.com/mbdavid/LiteDB/issues/1453#issuecomment-583781574
using var db = new LiteDatabase(@"Filename=database.db;Password='1234';connection=shared");
relevant code of Serilog.Sinks.LiteDB
as below:
new LiteDB.LiteDatabase
(
Serilog.Sinks.LiteDB.FileRoller.GetFilename
(
Serilog.Sinks.LiteDB.ConnectionStringParser.Parse
(connectionString)))so , we can config Serilog.Sinks.LiteDB
as below:
// use LiteDB shared Connection mode
var logFile = @"c:\tmp\logs.db";
var log = new LoggerConfiguration()
.WriteTo.LiteDB($"Filename={logFile};connection=shared")
.CreateLogger();
Maybe you can provide a PR for that? as i am not actively using this at the moment
On Tue, May 26, 2020, 14:20 Hendrik Kölbel @.***> wrote:
Is there a way to integrate the "shared" feature of LiteDB into this Serilog package? Possibly an option like serilog-sinks-async https://github.com/serilog/serilog-sinks-async as can be seen in the picture. [image: image] https://user-images.githubusercontent.com/31684940/82899673-ab1f0a80-9f5b-11ea-99bc-83011126a076.png
One option, for example, would be this:
Log.Logger = new LoggerConfiguration() .WriteTo.LiteDB("C:\Users\XXX\log.db", shared: true) .CreateLogger();
So that you can access the DB with another task while something is logged and reflect it in a LogViewer.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vip32/serilog-sinks-litedb/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABIDT5IR5CRH35RIBOHPZTRTOXZ7ANCNFSM4NKIIFOQ .
Is there a way to integrate the "shared" feature of LiteDB into this Serilog package? Possibly an option like serilog-sinks-async as can be seen in the picture.
One option, for example, would be this:
So that you can access the DB with another task while something is logged and reflect it in a LogViewer.