Creating facts live from a log file

Hi all,

I’d like perform queries against a live updating log file. Since I need to update the database with new facts, it seems that my options are to choose one of the approaches section 4.14 in the manual. I understand that it’s generally advised against modifying the database, so I thought I’d ask here if there are any examples of prolog being used for logs, or general advice about live updating databases.

Thanks,
Dave

All you probably need is assertz/1. There is nothing against modifying the database. There is something against passing (notably changing) temporary results inside a computation in the database for at least three reasons: (1) they are not subject to backtracking, destroying logical properties, (2) it is relatively slow and (3) the database is global and thus you need to take care of name clashes, cleanup and multi-threading.

Now the important question is how you get your data stream. You’ll need to monitor that, add the facts and possibly dispose too old facts. For just about any scenario for getting the data there is a clean solution in SWI-Prolog.