Question: NLog Configuration for SQLCipher Database
See original GitHub issueHello, got a question regarding NLog compatibility with SQLCipher. My question is expanded upon by the information I have entered below. Any assistance would be appreciated, and thanks in advance!
The current NLog version: (NLog 4.6.6)
The current config (file content or API calls):
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
internalLogLovel="Debug"
internalLogFile="file.txt"
internalLogToConsole="true"
internalLogIncludeTimestamp="true">
<targets>
<!-- DATABASE LOGGER-->
<target name="DBLog"
xsi:type="Database"
dbProvider="Microsoft.Data.SQLite.SQLiteConnection, Microsoft.Data.SQLite"
keepConnection="false"
connectionString="Data Source=redacted\redacted.db"
dbPassword="redacted"
commandText="INSERT INTO Logs (Message) VALUES ('Test');">
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="DBLog" />
</rules>
</nlog>
If relevant: the current result
2019-08-15 11:46:15.4789 Info Message Template Auto Format enabled
2019-08-15 11:46:15.5587 Info Adding target DatabaseTarget(Name=DBLog)
2019-08-15 11:46:15.6265 Info Found 38 configuration items
2019-08-15 11:46:15.7622 Info Configuration initialized.
2019-08-15 11:46:15.7751 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.6.6.10303. Product version: 4.6.6.
2019-08-15 11:47:04.6315 Error DatabaseTarget(Name=DBLog): Error when writing to database. Exception: Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 26: 'file is not a database'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteCommand.<PrepareAndEnumerateStatements>d__62.MoveNext()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
at NLog.Targets.DatabaseTarget.WriteEventToDatabase(LogEventInfo logEvent, String connectionString)
at NLog.Targets.DatabaseTarget.Write(LogEventInfo logEvent)
If relevant: the expected result
- I am receiving a “file is not a database error” that is leading me to believe either the encryption on the db is causing the error, or my config is incorrect.
- I expect the config file to be correctly setup in order to work with this SQLCipher (SQLite encrypted) database. Should NLog work with SQLCipher as it does with SQLite? Or is my assumption wrong that NLog should work with this DB Type, so I should continue to use the custom logger I built using our ORM?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
NLog Configuration for SQLCipher Database
Have you tried just doing this (Injecting the PRAGMA key in the commandText): <!-- DATABASE LOGGER--> <target name="DBLog" ...
Read more >NLOG with SQL Server and PostgreSQL in .Net Core
Here I am providing the steps to configure the Nlog for logging into the database in .net core. Install NLog.Web.
Read more >SECURING ANDROID SQLITE DB WITH SQLCIPHER AND JNI
Hello Guys, I am going to tell how to secure android sqlite database, for this we have used : 1) SQLCipher 2) JNI...
Read more >Untitled
#epizode 67 yonge street suite 200 automobile, Hindrances to problem solving ... Data replication for mobile computers pdf converter, Managed file transfer ...
Read more >[Fixed]-Problem with automated SQLite query via Node Red
Best coding solution for query Problem with automated SQLite query via Node Red. ... of larger string (genome) · NLog Configuration for SQLCipher...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well I’m just a guy that likes to read the manual when things are not working. I know nothing about SqlCipher.
I think it is wise that you do some experiments with
Microsoft.Data.SQLite.SQLiteConnection
, and see if you can make a code-example where you are able to write to the database.Based on the working code-example, then one can consider how to implement this in NLog DatabaseTarget.
Have you tried just doing this (Injecting the PRAGMA key in the
commandText
):Agreed.
Ultimately I believe we will be keeping the connection open, but for now this will do!
Thanks again!