4D v16.3LOG FILE TO JSON |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
LOG FILE TO JSON
LOG FILE TO JSON
The LOG FILE TO JSON command saves the current log file, or any specified log file, in JSON format. Once a log (binary file) is saved in JSON, its contents can be read and interpreted by the database administrator or any user in order to analyze database events, for example. In destFolderPath, pass the path of the folder where you want to store the JSON file. This file is named JournalExport.json. By default, the maximum size of the exported JSON file is 10 MB. When this size is reached, the file is closed and a new file is created. Limiting the size of each JSON file reduces memory requirements for analyzing the files. You can change the maximum size for the exported file by setting a value (in bytes) in the maxSize parameter. Passing 0 resets to the default size. Passing a negative value removes any size limit. By default, if the logPath parameter is omitted, the command saves the current log file. If you want to export a specific log file, pass its path in the logPath parameter. The log file must be a file with the ".journal" extension. If you want to export an archived log file (".4bl" extension), you need to convert it beforehand using the RESTORE command. You can pass an empty string ("") to display the standard open file dialog box, allowing the user to select the log file to save. The selected log file path is returned in the Document system variable. Note: When the command saves the current log file, the database is not locked. New operations can be executed while the file is being written on disk - these operations will not be included in the saved file. When you export the current log file, the fieldAtt parameter allows you to define how fields will be described in the exported attribute: by number (default), or by name. You can pass one of the following constants, found in the "Backup and Restore" constant theme:
Note: When you export an external log file, fields are always identified by their number. The saved JSON file contains all the operations recorded in the log, in the form of an array of JSON objects. Each object contains several properties describing the operation. Example: [ Note: If you passed Field attribute with name in the fieldAtt parameter, the "fields" object would look like this: ... The actual list of available properties depends on the operation type (i.e.: create record, delete record, modify record, create Blob, etc.). Here are the main properties:
You want to save the current log file in JSON: LOG FILE TO JSON("c:\\4Dv15\\ExportLogs") You want to save a specific log file in JSON with field names: LOG FILE TO JSON("c:\\4Dv15\\ExportLogs";0;"c:\\4Dv15\\Backup\\old_myDB.journal";Field attribute with name) The LOG FILE TO JSON command modifies the value of the OK and Document variables: if the JSON file was correctly saved, OK is set to 1 and Document contains the pathname of the journal file. If you passed "" in the logPath parameter and the user canceled the file selection dialog box, OK is set to 0 and Document contains an empty string. If the user selected an invalid file, OK is set to 0 and Document contains the pathname of the invalid file.
See also
|
PROPERTIES
Product: 4D HISTORY
Created: 4D v15 R4 ARTICLE USAGE
4D Language Reference ( 4D v16) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||