4D allows you to obtain a log of requests.
This file is named “logweb.txt” and is automatically located:
- with 4D in local mode and 4D Server, in the Logs folder located next to the database structure file.
- with 4D in remote mode, in the Logs subfolder of the 4D client database folder (cache folder).
The activation and configuration of the log file contents is carried out in the Database Settings on the Web/Log (type) page:
Note: The activation and deactivation of the log file of requests can also be carried out by programming using the SET DATABASE PARAMETER (4D v12) or WEB SET OPTION (4D v13 and higher) commands.
The log format menu provides the following options:
- No Log File: When this option is selected, 4D will not generate a log file of requests.
- CLF (Common Log Format): When this option is selected, the log of requests is generated in CLF format. With the CLF format, each line of the file represents a request, such as:
host rfc931 user [DD/MMM/YYYY:HH:MM:SS] "request" state length
Each field is separated by a space and each line ends by the CR/LF sequence (character 13, character 10).
- host: IP address of the client (ex. 192.100.100.10)
- rfc931: information not generated by 4D, it’s always - (a minus sign)
- user: user name as it is authenticated, or else it is - (a minus sign). If the user name contains spaces, they will be replaced by _ (an underscore).
- DD: day, MMM: a 3-letter abbreviation for the month name (Jan, Feb,...), YYYY: year, HH: hour, MM: minutes, SS: seconds
The date and time are local to the server.
- request: request sent by the client (ex. GET /index.htm HTTP/1.0)
- state: reply given by the server.
- length: size of the data returned (except the HTTP header) or 0.
Note: For performance reasons, the operations are saved in a memory buffer in packets of 1Kb before being written to disk. The operations are also written to disk if no request has been sent every 5 seconds.
The possible values of state are as follows:
200: OK
204: No contents
302: Redirection
304: Not modified
400: Incorrect request
401: Authentication required
404: Not found
500: Internal error
The CLF format cannot be customized.
- DLF (Combined Log Format): When this option is selected, the request log is generated in DLF format. DLF format is similar to CLF format and uses exactly the same structure. It simply adds two additional HTTP fields at the end of each request: Referer and User-agent.
- Referer: Contains the URL of the page pointing to the requested document.
- User-agent: Contains the name and version of the browser or software of the client at the origin of the request.
The DLF format cannot be customized.
- ELF (Extended Log Format): When this option is selected, the request log is generated in ELF format. The ELF format is very widespread in the world of HTTP browsers. It can be used to build sophisticated logs that meet specific needs. For this reason, the ELF format can be customized: it is possible to choose the fields to be recorded as well as their order of insertion into the file.
- WLF (WebStar Log Format): When this option is selected, the request log is generated in WLF format. WLF format was developed specifically for the 4D WebSTAR server. It is similar to the ELF format, with only a few additional fields. Like the ELF format, it can be customized.
Configuring the fields
When you choose the ELF (Extended Log Format) or WLF (WebStar Log Format) format, the “Weg Log Token Selection” area displays the fields available for the chosen format. You will need to select each field to be included in the log. To do so, use the arrow buttons or simply drag and drop the desired fields into the “Selected Tokens” area.
Note: You cannot select the same field twice.
The following table lists the fields available for each format (in alphabetical order) and describes its contents:
Field | ELF | WLF | Value |
BYTES_RECEIVED | | X | Number of bytes received by the server |
BYTES_SENT | X | X | Number of bytes sent by the server to the client |
C_DNS | X | X | IP address of the DNS (ELF: field identical to the C_IP field) |
C_IP | X | X | IP address of the client (for example 192.100.100.10) |
CONNECTION_ID | | X | Connection ID number |
CS(COOKIE) | X | X | Information about cookies contained in the HTTP request |
CS(HOST) | X | X | Host field of the HTTP request |
CS(REFERER) | X | X | URL of the page pointing to the requested document |
CS(USER_AGENT) | X | X | Information about the software and operating system of the client |
CS_SIP | X | X | IP address of the server |
CS_URI | X | X | URI on which the request is made |
CS_URI_QUERY | X | X | Request query parameters |
CS_URI_STEM | X | X | Part of request without query parameters |
DATE | X | X | DD: day, MMM: 3-letter abbreviation for month (Jan, Feb, etc.), YYYY: year |
METHOD | X | X | HTTP method used for the request sent to the server |
PATH_ARGS | | X | CGI parameters: string located after the “$” character |
STATUS | X | X | Reply provided by the server |
TIME | X | X | HH: hour, MM: minutes, SS: seconds |
TRANSFER_TIME | X | X | Time requested by server to generate the reply |
USER | X | X | User name if authenticated; otherwise - (minus sign). |
| | | If the user name contains spaces, they are replaced by _ (underlines) |
URL | | X | URL requested by the client |
Note: Dates and times are given in GMT.