I'm trying to enable file logging only if a specific debug code is entered, though I can't get it working. Logging works just fine if I enable it from the project settings window but it won't create a log file if I enable it through code:

Example:

func _ready():
	print(ProjectSettings.get_setting("logging/file_logging/enable_file_logging"))
	# prints "False"
	ProjectSettings.set("logging/file_logging/enable_file_logging", true)
	print(ProjectSettings.get_setting("logging/file_logging/enable_file_logging"))
	# prints "True"
	# ...but it doesn't create a log file, no matter if i disable it later or not

Any thoughts? Or would you suggest an alternative method for logging?

6 days later

Many project settings are only read when the project starts, which means that modifying them at run-time won't have any effect. You can set project settings before the project starts by creating a project settings override file; see this GitHub issue comment for details.

Thank you. I guess I will just write some variables to a text file instead.

3 years later