"Prevent cBot crashes due to full log.txt – add auto-rotation or logging API control"
"Prevent cBot crashes due to full log.txt – add auto-rotation or logging API control"
02 May 2025, 10:20
Ok, I have been digging into this with CodePilot, and came across this limitation. I used Print() stmt's in my bot for extensive debugging and tracing new code for accuracy. I filled the log file (log.txt) up very quickly, and found out that when log.txt fills up…. the Bot stops. So I manually created a new log file, and then the Bot would simply not restart at all. Luckily exiting CTrader, and restarting fixed the issue (I may have deleted the file altogether first). Ok, so here's the future scenario: your bot is running in the cloud, even though you created a separate external logging system to minimise(more like eliminate) log.txt entries, after several weeks of trades, the log fills up and your super stable lovable and dependable Bot just dies like a rat. And doesn't tell you first. You finally decide to check your bot, and find it it has been dead for days.
Guys and Gals, I know you are busy doing awesome things, but this is just not on. For goodness sake, please put in a Rotate function, where a new log is created when the old one gets too full. According to CodePilot, I cannot read the log.txt file to do it myself. Arghhhhh….. Please fix it.
firemyst
03 May 2025, 06:44
While it may be an issue, why don't you implement a work around yourself?
For instance, on every new trading day, have your bot start its own new log file to write to.
So you have one log file for every day.
I say it “may be an issue” because there are text file size limitations with programs, even in Windows. On Windows 11, Notepad uses the RichEdit control. The size limit was raised to about 1 GB, and attempting to open any file larger than that shows a dialog box suggesting that the user open it with a different text editor. In Windows 10 any Notepad large than 32MB can become unstable. So even if built in windows programs have issues with huge text file log sizes. you should expect other programs to as well.
Realistically, if you're logging that much information, you should be checking it regularly and clearing out the logs. Writing to huge log files will slow down any program as it waits for write actions to complete, and with automated trading, every nano-second counts when evaluating tick data.
@firemyst