Godot version:
Any
OS/device including version:
Any
Issue description:
print() to log file will not show the output until after the app is closed. This only happens when the executable is exported with Export With Debug flag unchecked.
Steps to reproduce:
Put this code in _ready() of a node script.
extends Node
func _ready():
for i in range(100):
print("i=%d" % i)
Make sure you have enabled logging in Project Settings.

Export With Debug flag before Save To File dialog.
Somehow it is not flushing output while app is running. This is not good if you are monitoring log output of an app.
Flushing causes overhead, so it makes sense that it happens only once if you disable debug, no?
No it does not make sense. If you are printing to logs then it should show up in the logs. The programmer decides if he wants it or not.
I wonder if this is related to #33255 somehow. See also https://github.com/godotengine/godot/issues/2233#issuecomment-168401696. While those issues are about printraw(), I suppose the underlying issue is similar.
I wonder if this is related to #33255 somehow. See also #2233 (comment). While those issues are about
printraw(), I suppose the underlying issue is similar.
printerr() works fine but also flushes out print() output if it comes after. So in some respects it can be a workaround for flush.
I deployed a server using Godot, which crashes due to an unknown event. Because there is nothing written to the log files, there is no chance to fix anything. I'm not sure if this is the same issue as discussed here. I tick "Enable File Logging" just as explained in the original post. The logs/log.txt file stays empty (0 Byte). I tried:
The log files stay empty. I have no idea how to fix that.
^
That sounds like a different issue.
See if this article adds anything to help https://medium.com/@silocoder/using-log-files-to-debug-godot-game-engine-apps-14c191df6580
Also I am wondering if reading a log file will force it to be flushed.
Also I am wondering if reading a log file will force it to be flushed.
Probably not; Godot handles when it should flush the standard output/error stream.
@wyattbiker I read this before, no luck.
I ended up using a pipe to write the printed output to a file...
Most helpful comment
No it does not make sense. If you are printing to logs then it should show up in the logs. The programmer decides if he wants it or not.