GamEsnitzhel
GamEsnitzhel

Reputation: 33

Can you make a log file in godot?

I have a game that currently crashes a lot and I wonder if I can make a log file to try and prevent that.

Upvotes: 3

Views: 6615

Answers (1)

Theraot
Theraot

Reputation: 40315

Go to the Project Menu -> Project Settings… -> General Tab -> Logging -> File Logging.

There are two options "Enable File Logging" and "Enable File Logging.pc". The former enables file logging as the name suggest, the latter overrides the value if the project is running on PC.

Given that you are probably editing the project in a PC platform, then "Enable File Logging.pc" being On is enough (which it is by default, i.e you don't have to do anything). Otherwise, make sure "Enable File Logging" is On.

The log files will be saved in the path specified in "Log Path". By default the path is "user://logs/log.txt", which means it will be in the Data Folder. You can go to the Project Menu -> Open Project Data Folder to open the folder. See also Data Paths.

As long as "Enable File Logging" is On, every time you run the game, Godot will create a new Log file. And it will include whatever would show up in the Output panel (bottom of the editor window), including what you output with print, print_debug, push_warning, push_error, and assert.

You could, of course, use the File class and write to a file whatever you want too.

Upvotes: 4

Related Questions