4D Blog

Home Product Optimize your ORDA code with requests logging

Optimize your ORDA code with requests logging

August 28, 2019

Product

Ever need to analyze the traffic of your ORDA requests between a client and the 4D server? Sometimes it may take a while to receive a response from the server, which can make you wonder if it’s due to network traffic or to an unoptimized request you’ve written! Thankfully, 4D v17 R6 makes it possible to determine the likely reason(s) for this latency with the new ORDA methods available on the ds object. They’re not only debugging functions, they also allow you to optimize your ORDA code with a better understanding of the sent requests.

Enable ORDA requests logging

The startRequestLog() member method is very flexible since it can log ORDA requests to either a file or memory.

log to a file

To log to a file, simply call startRequestLog() with a File object indicating where your ORDA requests will be logged. In the example below, we run a query on a non-indexed field which may take some time. Thanks to this new functionality, we can check the duration of our requests:

C_OBJECT($employees;$file)
$file:=File("/PACKAGE/Logs/ORDARequests.txt")
$file.delete()
ds.startRequestLog($file)
$employees:=ds.Employee.query("firstname = :1";"abcd") //firstname is not indexed
ds.stopRequestLog()

Each request is logged as a JSON representation of an object.

Here is the content of the ORDARequests.txt file:

[
{
...
"startTime":"2019-07-02T12:33:25.922Z",
"endTime":"2019-07-02T12:33:27.681Z",
"duration":4200,
"response":{ ...}
...
}
]

log to memory

Each request can be logged as an object in a collection which can be retrieved using the getRequestLog() member method. 

Since it returns a collection, you can use all of the available collection methods.

C_OBJECT($first;$e)
C_COLLECTION($log)

ds.startRequestLog(10) // Only the last 10 requests will be kept in memory
$first:=ds.Persons.all().first()
$e:=ds.Persons.query("name=:1";"Brown")
$log:=ds.getRequestLog()
ALERT("The longest request lasted: "+String($log.max("duration"))+" ms")
ds.stopRequestLog()

disable ORDA requests logging

To stop logging ORDA requests, just call the stopRequestLog() member method as shown in the examples above.

 

Discuss

Tags Client/Server, Logs, ORDA, v17 R6, v18

Latest related posts

  • November 14, 2025

    Event Report in 4D Qodly Pro: See Every Interactions at a Glance

  • November 14, 2025

    4D Qodly Pro: Page Zoom Controls

  • November 13, 2025

    macOS Tahoe, Windows 11, which operating systems for 4D 20 and 21?

Avatar
Marie-Sophie Landrieu-Yvert
- Product Owner - Marie-Sophie Landrieu-Yvert joined the 4D Product team as a Product Owner in 2017. In this role, she is responsible for writing user stories and translating them into functional specifications. She also ensures that the delivered feature implementation meets the customer's needs. Marie-Sophie graduated from the engineering school ESIGELEC and began her career as an engineer at IBM in 1995. She took part in various projects (maintenance and development projects) and worked as a COBOL developer. She then moved on to work as a UML designer and Java developer. More recently, her main responsibilities included analyzing and writing functional requirements, and coordinating business and development teams.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy