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

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Avatar
Marie-Sophie Landrieu-Yvert
• Product Owner • Marie-Sophie Landrieu-Yvert has joined the 4D Product team as a Product Owner in 2017. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Marie-Sophie graduated from the ESIGELEC Engineering School and began her career as an engineer at IBM in 1995. She participated on various projects (maintenance or build projects) and worked as a Cobol developer. Then she worked as an UML designer and Java developer. Lately her main roles were analyzing and writing functional requirements, coordinate business and development teams.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 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-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio 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