You can trace the SQL that ECO issues to the .NET Output/Trace window when diagnosing persistence behavior in an application that hosts ECO.
Trace SQL statements
Set Eco.Logging.EcoLogSwitches.LogSql to true, subscribe to the ECO trace listener, and start the listener.
Eco.Logging.EcoLogSwitches.LogSql = true;
Eco.Logging.EcoListener.Singleton.OnTraceLog += (sender, args) =>
{
System.Diagnostics.Trace.WriteLine(
System.Threading.Thread.CurrentThread.Name + ":" + args.Message);
};
Eco.Logging.EcoListener.StartListening();
With this configuration, ECO sends SQL trace messages through System.Diagnostics.Trace.WriteLine. The output includes the current thread name followed by the trace message.
For example, a message is written in this form:
<thread name>:<ECO trace message>
Use the trace output to inspect what SQL ECO performs while you reproduce a persistence issue. Keep the trace focused on the operation you are investigating so that the output remains readable.
What the code does
| Code | Effect |
|---|---|
EcoLogSwitches.LogSql = true
|
Enables ECO SQL logging. |
EcoListener.Singleton.OnTraceLog += ...
|
Subscribes a handler that receives ECO trace messages. |
Trace.WriteLine(...)
|
Writes each received message to the configured .NET trace output, prefixed with the current thread name. |
EcoListener.StartListening()
|
Starts the ECO listener so that subscribed handlers receive trace messages. |
Choose the right kind of logging
SQL tracing shows what ECO does internally. It is not the same as recording an application event.
| Your goal | Use |
|---|---|
| Inspect SQL issued by ECO while debugging | The SQL trace configuration on this page. |
| Write a message from a OCL action running in Turnkey or an MDrivenServer serverside action | LogEntry. For example: selfVM.LogEntry('hello I am logging here').
|
| Expose configurable OCL, EAL, persistence-mapper, SQL, and action logging in a CodeDress-based Turnkey application | Documentation:Logging OCL in Turnkey. |
| Inspect Turnkey log files or configure log4net output locations | Documentation:Serverinfo. |
| Investigate actions and scheduled work performed by MDrivenServer | Documentation:Debugging MDrivenServer Serverside actions. |
Related diagnostic approaches
If you need an audit trail of user navigations and actions in a Turnkey application, use the SysTurnkeyTraceLog pattern rather than SQL tracing. To record changes to model objects, use the object event methods described in Documentation:Acting on object changes and Documentation:Object Identity; use Documentation:OnStateChange when you need to track state changes.
