MT5: How can I flush Experts logs to disk without restarting the terminal?

Hello,

I would like to read MT5's standard Experts log file while the terminal remains running. I am using the Windows desktop version of MetaTrader 5.

New EA messages appear in the Toolbox's Experts tab, but the latest messages are not reflected in the corresponding log file on disk.

I have tried the following suggestions, but they have not updated the log file in my environment:

  1. Right-clicking in the Experts tab and selecting Open.
  2. Executing each of the following calls separately:

Print(NULL); Print(string(NULL)); Print((string)NULL);

In particular, I added Print((string)NULL) after trade executions, calling it once per batch for batch operations. A blank line appeared in the Experts tab, but I could not confirm that the latest log contents had been written to the file.

When I close MT5, the log file is updated at that point and includes the messages that had not previously appeared in the file.

I found the Print(NULL) / Print((string)NULL) suggestions in this earlier discussion:
Feature Request: Optional Flush for journal log.

Is there a reliable way in MT5 to force pending messages in the standard Experts log to be written to disk without closing or restarting the terminal?

Are there any build-specific limitations or execution conditions for the Open command or the Print calls above? Is there a supported setting, UI operation, or MQL5 function for this?

My question concerns flushing MT5's existing standard log, rather than writing a separate custom log file. If this is not currently supported, I would appreciate confirmation.

Thank you.

Feature Request: Optional Flush for journal log.
Feature Request: Optional Flush for journal log.
  • 2022.10.04
  • www.mql5.com
Hello, the service desk seems to accept feature requests. Perhaps MetaQuotes developer have a look on this...

As far as I know there is no call that flushes the terminal's own log. It writes in its own time, you saw it yourself, closing the terminal writes the rest.

I gave up on reading that file and write my own log next to it. Open it once in OnInit with FILE_READ|FILE_WRITE|FILE_SHARE_READ|FILE_TXT, FileSeek to the end, then after every line FileWrite and FileFlush. FileFlush puts it on disk right away and FILE_SHARE_READ lets another program read the file while the EA keeps it open. If the reader is outside the terminal add FILE_COMMON, then the file sits in the common Files folder and not in the data folder of one terminal.

Only thing, flush per event and not per tick or you hit the disk all the time.

taro Kappa:


  1. Right-clicking in the Experts tab and selecting Open.
This approach always works for me (when applied manually, I did not test any automation tools), so you need to be more specific, how do you initiate the command and check the file ouside MT5.