Summary
Description
This article aims to address these requirements:
- I want to run an engine trace for my X3 session.
- How do I run an engine trace from within a function?
- I want to run an engine trace on only a certain portion of my code.
Resolution
1. How to run an Engine Trace from within X3 generally
The Engine Tracing functionality changed significantly in 2021 R3 (Version 12 Patch 27). See the attached PDFs for more details on both the pre-V12 P27 and V12 P27+ methods of setting up Engine Tracing.
See the attached PDF files for more information:
- SageX3_engineTraceSetup_V12P27.pdf (Use this PDF for V12 Patch 27 onwards)
- SageX3_engineTraceSetup.pdf (All versions prior to V12 Patch 27)
2. How to run an Engine Trace interactively from within a function
You can manually enable and disable logging interactively following these steps:
- From within a function go to Help, Diagnosis, Calculator
- In the Calculation: field enter Openlog ("TRA", 2) and press ENTER (You should see 0 in results field). Note: TRA represents the folder that the log file will be written to in the working folder. 2 represents the engine log level.
- Do the processing you wish to trace
- To stop the log, go back to the Calculator, type Closelog() and press ENTER (You should see 0 in results field)
- To retrieve the log file from within the application:
Go to Log reading (Reports, Reports, Log Reading)
Find and Open up the log (it will start x3diary_...)
Click Copy to download the file
Alternatively, if you wish to retrieve it from the server then go to the TRA directory and look for the file starting "x3diary"
3. How to run/initiate an Engine Trace from within your 4GL code
Within your code, you are going to enter something similar to:
Local Integer RETTRACE
RETTRACE =openlog('TRA',5) **NOTE: Entering flag of "5" is just an example. Enter whatever flag is appropriate for your requirements
# The code you want to trace
RETTRACE=CloseLog()
Note: TRA represents the folder that the log file will be written to. The value corresponds to the flag as defined in the Online help for Engine trace.
Related Solutions
You can also refer to the presentation materials "Introduction to tracing classic functions" included in "Index page: Sage X3 Technical Support Tips and Tricks (March 2021)" and "Deep dive into the engine trace log file" included in "Index page: Sage X3 Technical Support Tips and Tricks (October 2022)"