I asked this question recently. However, everything has changed in the new version of glib that I just discovered.
Since the debug messages of glib version 2.32 are disabled and are not displayed by default. If you want to include them in an environment variable, then G_MESSAGES_DEBUG must be set for everyone.
G_MESSAGES_DEBUG=all /path/to/application
This option may be suitable for you, and there is no need for a log handler.
More details http://developer.gnome.org/glib/2.32/glib-running.html
source share