saleem-mirza / serilog-sinks-sqlite

A Serilog sink that writes to SQLite
Apache License 2.0
56 stars 44 forks source link

Compatibility with .NET Core 5.0? #31

Open gagwithgaffer opened 3 years ago

gagwithgaffer commented 3 years ago

Hello,

Using the basic example I just can't get this sink to function. I already tried another sink Lite DB which works in a similar way which is OK, but i would prefer to use SQLite.

Q. is there any known compatibility issues using .NET Core 5? Q. If the DB is not already created, should the sink automatically create one in the named folder path on startup? Q. Will the structured logging properties have their own columns in the DB Table, if not how can we do this? Q How is the sink accessing the DB? i.e. I want to access the same DB from other threads for reading the logs, likely using Entity Framework, concerned if there are concurrency issues to consider? Q. How could we implement a retention period with automatics deletion of oldest events? would we have to create our own cron/scheduled job to do this from our server code independently from the Sink? (we need to keep all records in one DB, not have them auto create new DBs in a rolling file system)

Code below from Program.cs

Log.Logger = new LoggerConfiguration()
                .ReadFrom.Configuration(configuration)
                .WriteTo.SQLite(@"Logs\log.db")
                .CreateLogger();

string logEventCategory = "System";
                string logEventType = "Application Startup";
                string logEventSource = "WebApp-PLUGIN";
                string logUserId = "";
                string logUserName = "";
                string logForename = "";
                string logSurname = "";
                string logData = "Application Starting Up";

                Log.Information(
                    "{@LogEventCategory}" +
                    "{@LogEventType}" +
                    "{@LogEventSource}" +
                    "{@LogUserId}" +
                    "{@LogUsername}" +
                    "{@LogForename}" +
                    "{@LogSurname}" +
                    "{@LogData}",
                    logEventCategory,
                    logEventType,
                    logEventSource,
                    logUserId,
                    logUserName,
                    logForename,
                    logSurname,
                    logData);

Thanks