-    // install temporary log sink: we can't use wxLogGui before wxApp is
-    // constructed and if we use wxLogStderr, all messages during
-    // initialization simply disappear under Windows
+    // Reset logging in case we were cleaned up and are being reinitialized.
+    wxLog::DoCreateOnDemand();
+
+    // force wxLog to create a log target now: we do it because wxTheApp
+    // doesn't exist yet so wxLog will create a special log target which is
+    // safe to use even when the GUI is not available while without this call
+    // we could create wxApp in wxEntryStart() below, then log an error about
+    // e.g. failure to establish connection to the X server and wxLog would
+    // send it to wxLogGui (because wxTheApp does exist already) which, of
+    // course, can't be used in this case