0

We're developing an application based on Yocto, distro Poky 1.7, and now we've to implement the logger, so we have installed the one already provided by our meta-oe layer:

Syslog-ng 3.5.4.1 libdbi 0.8.4.1 libdbi-drivers 0.8.3

Installation has been done without any problems and Syslog-ng can run correctly, except that it doesn't write to an existing sqlite database.

In the syslog-ng.conf file there is just one source, default unix stream socket /dev/log, and one destination, a local sqlite database (of just 4 columns). A simple program that writes 10 logs with the use of the C API 'syslog()' is used for test purposes.

  1. If the database already exists, empty or not, when running the demo program, no log message is written into the database;
  2. If the database doesn't exist, Syslog-ng creates it and is able to write log message until the board is rebooted. After that, we fall back into condition one, so no more log message could be save into the db.

After some days spent on this issue, I've found that this behaviour could be due to this sql statement (in function afsql_dd_validate_table(...) in afsql.c ):

SELECT * FROM tableName WHERE 0=1

I know that this is a useful statement to check existance of the table called 'tableName', and the WHERE 0=1 a always false condition to avoid to parse the whole table. Enabling Syslog-ng debug it seems that previous statement doesn't return any information about columns, so Syslog-ng think they don't exist and try adding them, causing an error since they already exist. That's why it doesn't write anything to the database.

Modifying the sql query with this one

SELECT * FROM tableName

I'm still unable to write any log message to the database if it is empty, but now it's possible to make all working in the right way if when the database is created a dummy record (row) is added. But this should not be the right way to work, has anyone faced thi issue and found a solution on how to make Syslog-ng logging with empty sqlite database?

Many thanks to everybody Regards

Andrea

Andre
  • 186
  • 11
  • Even empty result sets have columns. Sounds like a bug somewhere in syslog-ng or dbi. – CL. Oct 18 '16 at 07:09
  • @CL. That's my doubt too. I don't think it's a Syslog-ng problem, but more likely a dbi bug. In fact, going depth in the function calling tree, it seems that dbi structure containing sql statement result doesn't contain any information about fields (columns) after quering "SELECT * FROM tableName WHERE 1=0". Tried to mail this question to libdbi developers but no significant answer – Andre Oct 18 '16 at 14:22
  • Hi, can you try installing a newer syslog-ng version that uses a newer libdbi? 3.5.4 is rather old. – Robert Fekete Oct 18 '16 at 14:42
  • @RobertFekete Hi Robert, thanks for your advice. I've already trie installing a new version of Syslog-ng, the 3.6.4, but nothing changes. Try installing libdbi 0.9.0 results in a compilation error due to mismatch between libdbi-drivers function signature and the same used in the libdbi source; on the meta-embedded online repository I've not found any libdbi-drivers version newer than the one I'm using (0.8.3) – Andre Oct 19 '16 at 06:17

0 Answers0