What I make my EA write to the log, and how it changed how I debug
early on my EA logged almost nothing, and when something went wrong I was guessing. Now I log in a structured way, and it's changed how fast I can find problems.
For every signal, it writes the time, the symbol, the values that went into the decision and whether it traded or skipped. For skipped trades, it writes the reason, like spread too high, news filter, outside session, or max trades reached. For orders it logs the requested price, the fill price, the spread at the time and the response from the server.
When I look at a bad trade, I can see exactly what the EA saw and why it acted. The skipped reasons have been useful too, because if one filter is blocking most signals it's clear in the log.
I keep it readable by using a consistent line format. I can export the log and paste it into a spreadsheet to count things like the average slippage per session. It takes a bit of effort to write but pays off the first time something strange happens.
What I make my EA write to the log, and how it changed how I debug
Re: What I make my EA write to the log, and how it changed how I debug
An example of the line format I use, roughly: date and time, symbol, event type, then a few key values separated by semicolons. Event types are things like signal, skip, order, fill, modify and close. Keeping it to a fixed order means I can split the file into columns in a spreadsheet without any cleanup. I also add the magic number at the start of each line, so if more than one EA writes to the same log I can filter them apart easily.
It’s Fairman 
Re: What I make my EA write to the log, and how it changed how I debug
One thing I learned is not to log every tick. My first attempt wrote a line on every price change and the files grew huge and were impossible to read. Now the EA only logs when something happens: a new bar with a signal check, an order, a change to a trade, or a skip with a reason. That keeps the log small enough to scroll through and still captures everything I need when something odd shows up. Less noise in the file means I actually read it.
It’s Fairman 