KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Web Log Backup Naming Convention
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: September 25, 2023

A feature of the 4D Web Server is the ability to keep a log of requests. The requests are logged in a text file called logweb.txt placed in the Logs folder. Some web servers may receive alot of requests which can cause this file to increase in size. As such, another feature is the ability to "backup" the current log file and creating a new one. The backup works by renaming the current file and relocating it to a "\Logweb Archives" directory in the same location as where the logweb.txt file is located, and then creating a new logweb.txt file.

The naming convention of the backup is: Logweb_D{YYYYMMDD}T{########}.txt

The backup's name is basically appending a date-timestamp to the name.
The Date portion is D{YYYYMMDD} with "D" followed by the four digit year, two digit month, and two digit day.
The time part is less obvious with T{########}, after the "T", eight digits are displayed. The time is represented as the GMT/UTC time in milliseconds after 00:00:00 (midnight) for when the backup ocurred.

For example, take the following backup file with a name of: "Logweb_D20230918T07954550.txt"

The date is September 18th, 2023.
The time is the GMT/UTC time in milliseconds after midnight.
Take 07954550 and divide by 1000 to get the time in seconds after midnight: 07954.550.
Then convert the seconds to hours, minutes, and seconds to get: 02:12:34.550 GMT/UTC.
The time can then be converted to the proper timezone of the machine to determine what time the backup of the logfile was performed, such as subtracting 7 hours for Pacific time, to get 7:12:34.550 PM.

This conversion can easily be performed in 4D, by utilizing the Time command, which can convert seconds after midnight to a time value.
Using the previous example of 07954550, the following will result in $gmtTime = 02:12:35:

var $gmtTime : Time
$gmtTime:= Time(7954550/1000)

Alternatively, 4D's time variables can use the addition operator to add a number of seconds to another time. When a time variable is declared, it will be set to 00:00:00, so the following also works:
var $gmtTime : Time
$gmtTime+= (7954550/1000)