Description of log files
4D applications can generate several log files that are useful for debugging or optimizing their execution. Logs are usually started or stopped using selectors of the SET DATABASE PARAMETER or WEB SET OPTION commands and are stored in the Logs folder of the database.
Information logged needs to be analyzed to detect and fix issues. This section provides a comprehensive description of the following log files:
- 4DRequestsLog.txt
- 4DRequestsLog_ProcessInfo.txt
- HTTPDebugLog.txt
- 4DDebugLog.txt (standard & tabular)
- 4DDiagnosticLog.txt
- 4DIMAPLog.txt
- 4DPOP3Log.txt
- 4DSMTPLog.txt
- ORDA client requests log file
When a log file can be generated either on 4D Server or on the remote client, the word "Server" is added to the server-side log file name, for example "4DRequestsLogServer.txt"
Arquivos de Histórico compartilham alguns campos para que possa estabelecer uma cronologia e fazer conexões entre entradas quando depurar:
sequence_number
: this number is unique over all debug logs and is incremented for each new entry whatever the log file, so that you can know the exact sequence of the operations.connection_uuid
: for any 4D process created on a 4D client that connects to a server, this connection UUID is logged on both server and client side. It allows you to easily identify the remote client that launched each process.
4DRequestsLog.txt
Esses arquivos de histórico gravam petições normais realizadas pela máquina 4D Server ou a máquina remota 4D que executaram o comando (excluindo petições Web).
Como iniciar esse log:
- on the server:
SET DATABASE PARAMETER(4D Server log recording;1)
//server side
- on a client:
SET DATABASE PARAMETER(Client Log Recording;1)
//remote side
Esta declaração também começa um arquivo de histórico 4DRequestsLog_ProcessInfo.txt.
Headers
Este arquivo começa com os cabeçalhos abaixo:
- Log Session Identifier
- Hostname of the server that hosts the application
- User Login Name: login on the OS of the user that ran the 4D application on the server.
Conteúdos
Para cada petição, os campos abaixo estão logados:
Field name | Description |
---|---|
sequence_number | Unique and sequential operation number in the logging session |
time | Date and time using ISO 8601 format: 'YYYY-MM-DDTHH:MM:SS.mmm' |
systemid | System ID |
component | Component signature (e.g., '4SQLS' or 'dbmg') |
process_info_ | index Corresponds to the "index" field in 4DRequestsLog_ProcessInfo.txt log, and permits linking a request to a process. |
request | Request ID in C/S or message string for SQL requests or LOG EVENT messages |
bytes_in | Number of bytes received |
bytes_out | Number of bytes sent |
server_duration | exec_duration | Depends on where the log is generated: |
write_duration | Time taken in microseconds for sending the: |
task_kind | Preemptive or cooperative (respectively 'p' or 'c') |
rtt | Time estimate in microseconds for the client to send the request and the server to acknowledge it. A to D and E to H in image below. |
Fluxo de petição:
4DRequestsLog_ProcessInfo.txt
Este arquivo de histórico registra a informação em cada processo criado na máquina 4D Server ou na máquina remota 4D que executa o comando (excluindo petições Web).
Como iniciar esse log:
- on the server:
SET DATABASE PARAMETER(4D Server log recording;1) //server side
- on a client:
SET DATABASE PARAMETER(Client Log Recording;1) //remote side
Esta declaração também começa o arquivo de histórico 4DRequestsLog.txt.
Headers
Este arquivo começa com os cabeçalhos abaixo:
- Log Session Identifier
- Hostname of the server that hosts the application
- User Login Name: login on the OS of the user that ran the 4D application on the server.
Conteúdos
Para cada processo, os campos abaixo são registrados:
Field name | Description |
---|---|
sequence_number | Unique and sequential operation number in the logging session |
time | Date and time using ISO 8601 format: "YYYY-MM-DDTHH:MM:SS.mmm" |
process_info_index | Unique and sequential process number |
CDB4DBaseContext | DB4D component database context UUID |
systemid | System ID |
server_process_id | Process ID on Server |
remote_process_id | Process ID on Client |
process_name | Process name |
cID | Identifier of 4D Connection |
uID | Identifier of 4D Client |
IP Client | IPv4/IPv6 address |
host_name | Client hostname |
user_name | User Login Name on client |
connection_uuid | UUID identifier of process connection |
server_process_unique_id | Unique process ID on Server |
HTTPDebugLog.txt
This log file records each HTTP request and each response in raw mode. Whole requests, including headers, are logged; optionally, body parts can be logged as well.
Como iniciar esse log:
WEB SET OPTION(Web debug log;wdl enable without body)
//other values are available
The following fields are logged for both Request and Response:
Field name | Description |
---|---|
SocketID | ID of socket used for communication |
PeerIP | IPv4 address of host (client) |
PeerPort | Port used by host (client) |
TimeStamp | Timestamp in milliseconds (since system startup) |
ConnectionID | Connection UUID (UUID of VTCPSocket used for communication) |
SequenceNumber | Unique and sequential operation number in the logging session |
4DDebugLog.txt (standard)
Esses registros de histórico gravam cada evento que ocorreu ao nível de programação de 4D. Modo padrão oferece uma vista básica de eventos.
Como iniciar esse log:
SET DATABASE PARAMETER(Debug Log Recording;2)
//standard, all processes
SET DATABASE PARAMETER(Current process debug log recording;2)
//standard, current process only
Os campos abaixo estão registrados para cada evento:
Column # | Description |
---|---|
1 | Unique and sequential operation number in the logging session |
2 | Date and time in ISO 8601 format (YYYY-MM-DDThh:mm:ss.mmm) |
3 | Process ID (p=xx) and unique process ID (puid=xx) |
4 | Stack level |
5 | Can be Command Name/ Method Name/Message/ Task Start Stop info/Plugin Name, event or Callback/Connection UUID |
6 | Time taken for logging operation in milliseconds |
4DDebugLog.txt (tabular)
Esse arquivo de histórico registra cada evento que ocorrer ao nível de programação 4D em um formato tabulado e compacto que inclui informação adicional (comparado ao formato padrão).
Como iniciar esse log:
SET DATABASE PARAMETER(Debug Log Recording;2+4)
//extended tabbed format, all processes
SET DATABASE PARAMETER(Current process debug log recording;2+4)
//extended, current process only
Os campos abaixo estão registrados para cada evento:
Column # | Field name | Description |
---|---|---|
1 | sequence_number | Unique and sequential operation number in the logging session |
2 | time | Date and time in ISO 8601 format (YYYY-MM-DDThh:mm:ss.mmm) |
3 | ProcessID | Process ID |
4 | unique_processID | Unique process ID |
5 | stack_level | Stack level |
6 | operation_type | Tipo operação histórico. Esse valor pode ser um valor absoluto:
operation_type , operation e operation_parameters tem o mesmo valor que o nível de stack registrado na coluna stack_opening_sequence_number column. For example:
|
7 | operation | Pode representar (dependendo do tipo da operação): |
8 | operation_parameters | Parâmetros passados a comandos, métodos ou plugins |
9 | form_event | Evento formulário se houver: vazio em outros casos (suponha que a coluna é usada quando o código for executado em um método formulário ou método objeto) |
10 | stack_opening_sequence_number | Só para níveis stack fechamento: número sequencia do nível correspondente de abertura de stack |
11 | stack_level_execution_time | Só para níveis de stack de fechamento: tempo decorrido em microssegundos da ação de histórico atual; só para os níveis de stack de fechamento (ver décima coluna em linhas 123 e 124 no histórico acima) |
4DDiagnosticLog.txt
Esse arquivo registra vários eventos relacionados à operação de aplicação e sua leitura humana. Pode incluir informação personalizada nesse arquivo usando o comando LOG EVENT
Como iniciar esse log:
SET DATABASE PARAMETER(Diagnostic log recording;1) //start recording
Os campos abaixo estão registrados para cada evento:
Field Name | Description |
---|---|
sequenceNumber | Unique and sequential operation number in the logging session |
timestamp | Date and time in ISO 8601 format (YYYY-MM-DDThh:mm:ss.mmm) |
loggerID | Optional |
componentSignature | Optional - internal component signature |
messageLevel | Info, Warning, Error |
message | Description of the log entry |
Dependendo do evento, vários outros campos podem ser registrados, como task, socket, etc.
4DSMTPLog.txt, 4DPOP3Log.txt, and 4DIMAPLog.txt
Esses históricos registram cada troca entre a aplicação 4D e o servidor de mail (SMTP, POP3, IMAP) que foram iniciados pelos comandos abaixo:
- SMTP - SMTP New transporter
- POP3 - POP3 New transporter
- IMAP - IMAP New transporter
Os arquivos de histórico podem ser produzidos em duas versões:
a regular version:
- named 4DSMTPLog.txt, 4DPOP3Log.txt, or 4DIMAPLog.txt
- no attachments
- uses an automatic circular file recycling each 10 MB
- intended for usual debugging
To start this log:
SET DATABASE PARAMETER(SMTP Log;1) //start SMTP log SET DATABASE PARAMETER(POP3 Log;1) //start POP3 log SET DATABASE PARAMETER(IMAP Log;1) //start IMAP log
4D Server: Click on the Start Request and Debug Logs button in the Maintenance Page of the 4D Server administration window.
This log path is returned by the
Get 4D file
command.an extended version:
- attachment(s) included no automatic recycling
- custom name
- reserved for specific purposes
To start this log:
$server:=New object ... //SMTP $server.logFile:="MySMTPAuthLog.txt" $transporter:=SMTP New transporter($server) // POP3 $server.logFile:="MyPOP3AuthLog.txt" $transporter:=POP3 New transporter($server) //IMAP $server.logFile:="MyIMAPAuthLog.txt" $transporter:=IMAP New transporter($server)
Conteúdos
Para cada petição, os campos abaixo estão logados:
Column # | Description |
---|---|
1 | Unique and sequential operation number in the logging session |
2 | Date and time in RFC3339 format (yyyy-mm-ddThh:mm:ss.ms) |
3 | 4D Process ID |
4 | Unique process ID |
5 |
|
ORDA client requests
Esse registro grava cada petição ORDA enviada de uma máquina remota. Pode dirigir informação de histórico a uma memória ou a um arquivo em disco. O nome e rota desse arquivo pode ser escolhido.
Como iniciar esse log:
//to be executed on a remote machine
ds.startRequestLog(File("/PACKAGE/Logs/ordaLog.txt"))
//can be also sent to memory
Se quiser usar esse número de sequência único em histórico de petições ORDA, necessita ativá-lo:
//to be executed on a remote machine
SET DATABASE PARAMETER(Client Log Recording;1)
//to enable log sequence number
ds.startRequestLog(File("/PACKAGE/Logs/ordaLog.txt"))
//can be also sent to memory
SET DATABASE PARAMETER(Client Log Recording;0)
//disabling sequence number
Os campos abaixo são registrados para cada petição:
Field name | Description | Exemplo |
---|---|---|
sequenceNumber | Unique and sequential operation number in the logging session | 104 |
url | Client ORDA request URL | "rest/Persons(30001)" |
startTime | Starting date and time using ISO 8601 format | "2019-05-28T08:25:12.346Z" |
endTime | Ending date and time using ISO 8601 format | "2019-05-28T08:25:12.371Z" |
duration | Client processing duration (ms) | 25 |
response | Server response object | {"status":200,"body":{"__entityModel":"Persons",[...]}} |
Using a log configuration file
You can use a log configuration file to easily manage log recording in a production environment. This file is preconfigured by the developer. Typically, it can be sent to customers so that they just need to select it or copy it in a local folder. Once enabled, the log configuration file triggers the recording of specific logs.
How to enable the file
There are several ways to enable the log configuration file:
- On 4D Server with interface, you can open the Maintenance page and click on the Load logs configuration file button, then select the file. In this case, you can use any name for the configuration file. It is immediately enabled on the server.
- You can copy the log configuration file in the Settings folder of the project. In this case, the file must be named
logConfig.json
. It is enabled at project startup (only on the server in client/server). - With a built application, you can copy the
logConfig.json
file in the following folder:- Windows:
Users\[userName]\AppData\Roaming\[application]
- macOS:
/Users/[userName]/Library/ApplicationSupport/[application]
- Windows:
If you want to enable the log configuration file for all projects in stand-alone, server and remote 4D applications, you can copy the
logConfig.json
file in the following folder: - Windows:Users\[userName]\AppData\Roaming\4D or \4D Server
- macOS:/Users/[userName]/Library/ApplicationSupport/4D or /4D Server
JSON file description
The log configuration file is a .json
file that can contain the following properties:
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Logs Configuration File",
"description": "A file that controls the state of different types of logs in 4D clients and servers",
"type": "object",
"properties": {
"forceLoggingConfiguration": {
"description": "Forcing the logs configuration described in the file ingoring changes coming from code or user interface",
"type": "boolean",
"default": true
},
"requestLogs": {
"description": "Configuration for request logs",
"type": "object",
"properties": {
"clientState": {
"description": "Enable/Disable client request logs (from 0 to N)",
"type": "integer",
"minimum": 0
},
"serverState": {
"description": "Enable/Disable server request logs (from 0 to N)",
"type": "integer",
"minimum": 0
}
}
},
"debugLogs": {
"description": "Configuration for debug logs",
"type": "object",
"properties": {
"commandList": {
"description": "Commands to log or not log",
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
"state": {
"description": "integer to specify type of debuglog and options",
"type": "integer",
"minimum": 0
}
}
},
"diagnosticLogs":{
"description": "Configuration for debug logs",
"type": "object",
"properties": {
"state":{
"description": "Enable/Disable diagnostic logs 0 or 1 (0 = do not record, 1 = record)",
"type": "integer",
"minimum": 0
}
}
},
"httpDebugLogs": {
"description": "Configuration for http debug logs",
"type": "object",
"properties": {
"level": {
"description": "Configure http request logs",
"type": "integer",
"minimum": 0,
"maximum": 7
},
"state": {
"description": "Enable/Disable recording of web requests",
"type": "integer",
"minimum": 0,
"maximum": 4
}
}
},
"POP3Logs": {
"description": "Configuration for POP3 logs",
"type": "object",
"properties": {
"state": {
"description": "Enable/Disable POP3 logs (from 0 to N)",
"type": "integer",
"minimum": 0
}
}
},
"SMTPLogs": {
"description": "Configuration for SMTP logs",
"type": "object",
"properties": {
"state": {
"description": "Enable/Disable SMTP log recording (form 0 to N)",
"type": "integer",
"minimum": 0
}
}
},
"IMAPLogs": {
"description": "Configuration for IMAP logs",
"type": "object",
"properties": {
"state": {
"description": "Enable/Disable IMAP log recording (form 0 to N)",
"type": "integer"
}
}
},
"ORDALogs": {
"description": "Configuration for ORDA logs",
"type": "object",
"properties": {
"state": {
"description": "Enable/Disable ORDA logs (0 or 1)",
"type": "integer"
},
"filename": {
"type": "string"
}
}
}
}
}
Exemplo
Here is an example of log configuration file:
{
"forceLoggingConfiguration": false,
"requestLogs": {
"clientState": 1,
"serverState": 1
},
"debugLogs": {
"commandList":["322","311","112"],
"state": 4
},
"diagnosticLogs":{
"state" : 1
},
"httpDebugLogs": {
"level": 5,
"state" : 1
},
"POP3Logs": {
"state" : 1
},
"SMTPLogs": {
"state" : 1
},
"IMAPLogs": {
"state" : 1
},
"ORDALogs": {
"state" : 1,
"filename": "ORDALog.txt"
}
}