"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.
Replies
davidrob
04 May 2025, 01:24
RE: "Prevent cBot crashes due to full log.txt – add auto-rotation or logging API control"
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.
@davidrob
davidrob
04 May 2025, 01:40
RE: RE: "Prevent cBot crashes due to full log.txt – add auto-rotation or logging API control"
davidrob said:
firemyst said:
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.
Yes, definitely will be implementing my own system, it's nearly done. Yes, my logs are big when debugging. But 1Gb? I will check again , but I know the file was nowhere near that size. Either way, its a matter of principle. It is only a few lines of code to rename and create a new file when it reaches a size limit, to solve a potentially serious problem. I have decided to go with the flow. IT is a good idea to periodically restart any full-time program. So maybe it is best to just accept that, and when markets are closed, simply close and restart it once a week or month. Other chores could be done too, like assembling historical trade info into an exportable format for decent reports, running data analysis, re-opting (if that is possible to do automatically), etc.
@davidrob
davidrob
04 May 2025, 01:40
RE: RE: "Prevent cBot crashes due to full log.txt – add auto-rotation or logging API control"
davidrob said:
firemyst said:
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.
Yes, definitely will be implementing my own system, it's nearly done. Yes, my logs are big when debugging. But 1Gb? I will check again , but I know the file was nowhere near that size. Either way, its a matter of principle. It is only a few lines of code to rename and create a new file when it reaches a size limit, to solve a potentially serious problem. I have decided to go with the flow. IT is a good idea to periodically restart any full-time program. So maybe it is best to just accept that, and when markets are closed, simply close and restart it once a week or month. Other chores could be done too, like assembling historical trade info into an exportable format for decent reports, running data analysis, re-opting (if that is possible to do automatically), etc.
@davidrob
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