<< Click to Display Table of Contents >>

Navigation:  Program use > Configuration > Log files >

Log rotation

The main function of Serial Printer Logger is logging data to a file (so-called, log file). The "Log rotation" tab has a rich set of options for it. (fig. 4.1.1).

 

options-logformat

Fig. 4.1.1 Log-file forming modes

 

First of all, select log file what you can configure:

 

Log file for data received - all data received will be saved using these settings.

Log file for data sent - these settings will be used to save sent data. If you want to save data to the same file, as data received, then select the "Log file rotation for data sent" option from the list and enable two options: "Create log files on disk" and "Write to log for data received." Of course, you should configure a log rotation for data received before.

 

Set the "Create log file on disk" option to the checked state. Then you can set path to a folder, where files will be created with the help of a dialog window, which will be showed up after clicking a button with the "Folder" picture. You should select a necessary folder in the dialog window and click the "OK" button.

 

Log file path - the full path to a local or network folder, where the program will create new log files. The network path should be specified as: \\COMPUTER NAME\Folder\

 

Note: If the program works with network files, it greatly increases data flow through your network and decreases writing speed. Please, consider creating small log files. If your incoming data flow is fast, you may create log files locally. Later, you may sync a local folder with a remote folder using any 3rd party utility.

 

A log file name can be stamped with date and time. In this case, a new log file is created periodically. The format of a timestamp depends on the selected period. For instance, if the "File name prefix" field is set to "sample," the "File extension" field to "log," and the "File name format" option is "Daily," then each log file created will have the format "sampleYYYYMMDD.log". On March 21st, 2003, the log file will be "sample20030321.log". Please, note, that the final extension (after the final period), remains at the end of the file name.

 

Write to log - the option allows you to select when the program writes data to a log file. This feature is disabled in some loggers, and if the parser plugin is not available.

 

Before parsing - the program saves all incoming data without any modifications. If an external device sends binary data, the logger will create binary files.

After parsing - the program saves data after parsing. Generally, it is a parsed data packet.

After filtering - the program saves data after all filter plugins. The logger saves the content of the "FULL_DATA_PACKET" variable. A filter plugin may transform or fully change the variable. If you do not use any filter plugin, then this mode works as the previous.

Screen content - the program saves data to a log file as you see it in the main window. Generally, it is text content; therefore, the program creates a text log file.

 

The log rotation mode is defined by the following key parameters:

 

File name prefix - the text string, which will be added at file name beginning. The prefix may contain special placeholders like {NAME}. If you create log files before parsing the NAME can be any date formatting values below. For example: "data{YYYY}_{MM}_{DD}" returns a prefix like "data2019_01_01". If you create log files after parsing or filtering, you may use any parser variable. Then the file name may depend on some value in your incoming data.

File name extension - the text string, which will be a file extension (characters after the dot).

 

Limit size - the "Limit size" field specifies the maximum size in kilobytes of any log file. If you specify the zero file size, then the file size is not limited.

 

You may select from the following modes:

 

1.Clear file - if the log file size will exceed the limit specified, then the log file content will be deleted, and file filling will start from the beginning.

2.Rename old - if the log file size will exceed the limit specified, then the existing log file will be renamed.

3.Shift (no threshold) - the older data over the limit specified will be removed from the log file.

4.Shift (with threshold) - in this mode the program will wait when the file size will exceed the limit specified + the threshold value. After this, the older data over the limit specified will be removed from the log file.

 

If the program continuously works for a long time, it is possible that the log file will have a large size and this file will be inconvenient for looking and analyzing. Therefore, there is the possibility to create files in dependence with the time on a computer. You can select one variant predefined or set up a new one:

 

Daily - the file will be created with a name containing a prefix, and date in format DDMMYYYY, where DD is two-digit day sign, MM is two-digit month sign, and YYYY is four digits of the current year. The filename extension will be added at the end of the file.

Monthly - the file will be created with a name containing a prefix, and date in MMYYYY format. The filename extension will be added at the end of the file.

Each data packet in different file - in this mode, the program splits data flow to a different file. In this mode you should configure the parser or the program will split a data by timeout about 300 milliseconds.

Don't create new file - in this mode, the program will write all data to one file. It is recommended for a small data flow. Otherwise, your log file will be too big, and a performance of the program will fall down.

User's format - a file will be created with a name containing a prefix and date in showed by you format (for example, DDMMYYYY). The filename extension will be added at the end of the file. The file may not contain format signs, then file name will be constant. You should not use characters, that the OS doesn't allow in a file name, such as "/,\.*,?" and some others.

Weekly - create a new file every week. The file name will contain a week number.

After data timeout - the program will create a new file if the program didn't receive any data at the specified interval.

Hourly - the file will be created with a name containing a prefix, and date in format YYYYMMDDHH, where HH is two-digit hour sign, DD is two-digit day sign, MM is two-digit month sign and YYYY is four digits of the current year. The filename extension will be added at the end of the file.

Constantly named file - the current log file will have a constant name. When creating a new file, the existing log file will be saved using the new file name that will contain a date and time stamp.

 

Date and time formatting codes:

 

D        - a day number (1-31).

DD        - a day number with a leading zero (01-31).

DDD        - a day of the week in the text form (Mon-Sat), according to the regional settings on this computer.

DDDD        - a day of the week in the full text form (Monday-Saturday), according to the regional settings on this computer.

M        - a month number (1-12).

MM        - a month with a leading zero (01-12).

MMM        - a month name in the text form (Jan-Dec), according to the regional settings on this computer.

MMMM        - the full month name (January- December).

YY        - last two digits of the year (00-99).

YYYY        - the full year number (0000-9999).

H        - the hour number (0-23).

HH        - the hour number with a leading zero (00-23).

N        - minutes (0-59)

NN        - minutes with a leading zero (00-59).

S        - seconds (0-59).

SS        - seconds with a leading zero (00-59).

 

Example: You want to create a log file every hour. It is desired that file name starts from "sample_log" and the file extension "txt".

 

Answer: set file prefix = sample_log_, file extension= txt (without dot!). In file name format show HHDDMMYYYY. Now the file will be created every hour. Naturally, you can set any formatting characters combination, described higher.

 

If you want to access to a log file while the program work, then you should configure access mode settings for the log file in the next chapter.

 

Add date/time stamp to file name - this option is available for modes #4 and #7 and allows adding date and time to the file name.

 

Add data source ID to file name - if this option is activated, then the program will append the data source name at the beginning of the file name, for example, COM1-sample20030321.log.

 

Write data/time stamp to file before writing data - if this option is activated, then the program will write a date/time stamp to a file before each data portion.

 

Overwrite existing files - this option is available for modes #4 and #7 and allows you to delete an existing log file before creating a new log file.