More about the log file
Most of the content of this section is taken directly from 4D Doc Centre website.
Performing regular backups of data is important but does not allow (in case of incident) restoring data entered since the last backup. To respond to this need, 4D now offers a specific tool: the log file. This file allows ensuring permanent security of database data.In addition, 4D works continuously with a data cache in memory. Any changes made to the data of the database are stored temporarily in the cache before being written to the hard disk. This accelerates the operation of applications; in fact, accessing memory is faster than accessing the hard disk.
If an incident occurs in the database before the data stored in the cache could be written to the disk, you must include the current log file in order to restore the database entirely.Finally, 4D has functions that analyze the contents of the log file, making it possible to rollback the operations carried out on the data of the database.
How the log file works?
The log file generated by 4D contains all operations performed on a database, which are logged sequentially. As such, each operation performed by a user causes two simultaneous actions: the first one in the database (instruction is executed normally) and the second one in the log file (the description of the operation is recorded). The log file is created independently without disturbing or slowing down the work of the user. A database can only work with one log file at a time. The log file records the following types of operations:
- Opening and closing of the data file,
- Opening and closing of the process (contexts),
- Adding of records or BLOBs,
- Modifying of records,
- Deleting of records,
- Creating and closing of transactions,
For more information about these actions, refer to the Activity analysis page. 4D manages the log file. It takes into account all operations that affect the data file equally, regardless of any manipulations performed by a user, 4D methods, the SQL engine, 4D plug-ins (4D Write, 4D View, etc.), or a Web browser.The following illustration sums up how the log file works:
The current log file is automatically saved with the current data file. This mechanism has two distinct advantages:
- Its avoids saturating the disk volume where the log file is stored. Without a backup, the log file would get bigger and bigger with use, and would eventually use all available disk space. For each data file backup, 4D or 4D Server closes the current log file and immediately starts a new, empty file, thereby avoiding the risk of saturation. The old log file is then archived and eventually destroyed depending on the mechanism for managing the backup sets.
- It keeps log files corresponding to backups in order to be able to parse or repair a database at a later point in time. The integration of a log file can only be done in the database to which it corresponds. It is important, in order to be able to properly integrate a log file into a backup, to have backups and log files archived simultaneously.