serilog-sinks-sqlite icon indicating copy to clipboard operation
serilog-sinks-sqlite copied to clipboard

Add Pragma generic list to be included in SQLite connection string

Open EntityBox opened this issue 5 months ago • 0 comments

Adding pragma statements to SQLite is vital for the underlaying database.

By adding a generic list, the end user could add items manually that they would like to tweak on their instance.

Because this relates to logging, it could be easy for the user to add in the pragma_auto_vacuum in the list and ensure there is no need to call the vacuum command after bulk deletes.

This PR is adding List<string> to the configuration extension that passes it through to the connection string to be appended.

Example:

List<string> PragmaItems = new List<string>
{
    {"auto_vacuum=FULL"}
};

and then in the LoggerConfiguration:

.WriteTo.SQLite(System.IO.Path.Combine("C:\SomeDirectory", "SomeSQLiteDB.db"),pragmas: PragmaItems)

The result would end with the SQLiteConnectionStringBuilder from the current default: data source="C:\SomeDirectory\SomeSQLiteDB";journal mode=Memory;synchronous=Normal;cache size=500;page size=4096;max page count=2560 to: data source="C:\SomeDirectory\SomeSQLiteDB";journal mode=Memory;synchronous=Normal;cache size=500;page size=4096;max page count=2560;auto_vacuum=FULL;

EntityBox avatar Sep 08 '24 11:09 EntityBox