Open Szesan opened 2 years ago
C# exceptions are not logged, but if you use the printing methods (GD.PushError
, GD.PushWarning
, GD.Print
...) those messages will be written to the log. Godot methods use these methods internally so those should appear in the log.
I would recommend you to use these methods in your C# project as well and avoid exceptions if you can. You can also workaround this using try/catch:
try
{
throw new Exception("Something went wrong.");
}
catch (Exception e)
{
GD.PushError(e.ToString());
}
C# exceptions are not logged, but if you use the printing methods (
GD.PushError
,GD.PushWarning
,GD.Print
...) those messages will be written to the log. Godot methods use these methods internally so those should appear in the log.I would recommend you to use these methods in your C# project as well and avoid exceptions if you can. You can also workaround this using try/catch:
try { throw new Exception("Something went wrong."); } catch (Exception e) { GD.PushError(e.ToString()); }
With all due respect, I don't think so.
Those exceptions are printed to the console, they should be printed in the log as well without me having to dilute my code with hundreds of unnecessary, and performance hindering try catch blocks.
If you are suggesting this as a temporary "hack" to debug some specific issue in a particular case, then it's fine. But if you are suggesting that the default logging is good as it is now, because it's possible to catch exceptions with try catch blocks, then your response makes no sense to me.
Sorry, I actually agree that C# exceptions should be logged just like any other error.
Sorry, I actually agree that C# exceptions should be logged just like any other error.
No probs. Probably I wasn't crystal clear in my proposal. Normally I'm not throwing exceptions deliberately, exceptions just happen unfortunately, because my code is not perfect. In the demo project I deliberately threw an exception to demonstrate what's happening when an exception happens naturally. If you see what I mean.
Normally I don't use the keyword "throw" in my godot project, is what I mean. :)
This is still reproducible on 4.2.1 according to https://forum.godotengine.org/t/why-are-engine-error-messages-not-in-log-file/46768.
Godot version
v3.3.3.stable.mono.
System information
Windows 10
Issue description
If you enable file logging in project settings, the log files are successfully created at the given location. However these logs are completely useless, since no exception is recorded in them.
Every log file which was created on my system contains the same data:
"Godot Engine v3.3.3.stable.mono.official.b973f997f - https://godotengine.org OpenGL ES 2.0 Renderer: GeForce MX150/PCIe/SSE2 OpenGL ES Batching: ON
Mono: Log file is: '[log poath]'"
No exceptions recorded, even if the program crashes with an obvious exception.
I've attached a simple project to demonstrate the issue.
Steps to reproduce
Create a project
Enable file logging
Throw an exception
Check the log
Minimal reproduction project
TestLogging.zip