diff --git a/bsd-user/main.c b/bsd-user/main.c
index 0d3156974c..96787b27ef 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -743,6 +743,7 @@ int main(int argc, char **argv)
     if (argc <= 1)
         usage();
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
     qemu_init_cpu_list();
     module_call_init(MODULE_INIT_QOM);
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 0a8d9cc9ea..2852e9df2a 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -49,6 +49,8 @@ bool error_report_once_cond(bool *printed, const char *fmt, ...)
 bool warn_report_once_cond(bool *printed, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
+void qemu_init_logging(void);
+
 /*
  * Similar to error_report(), except it prints the message just once.
  * Return true when it prints, false otherwise.
diff --git a/linux-user/main.c b/linux-user/main.c
index 923cbb753a..de9ff462e9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -600,6 +600,7 @@ int main(int argc, char **argv, char **envp)
     int ret;
     int execfd;
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
     qemu_init_cpu_list();
     module_call_init(MODULE_INIT_QOM);
diff --git a/qemu-img.c b/qemu-img.c
index ad04f59565..9214392565 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4912,6 +4912,7 @@ int main(int argc, char **argv)
     signal(SIGPIPE, SIG_IGN);
 #endif
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
     error_set_progname(argv[0]);
     qemu_init_exec_dir(argv[0]);
diff --git a/qemu-io.c b/qemu-io.c
index 6df7731af4..ad38d12e68 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -524,6 +524,7 @@ int main(int argc, char **argv)
     signal(SIGPIPE, SIG_IGN);
 #endif
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
     progname = g_path_get_basename(argv[0]);
     qemu_init_exec_dir(argv[0]);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index ca7109652e..2cac038230 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -570,6 +570,7 @@ int main(int argc, char **argv)
     signal(SIGPIPE, SIG_IGN);
 #endif
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
     qcrypto_init(&error_fatal);
 
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index e7af637232..523f8b237c 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -895,6 +895,7 @@ int main(int argc, char **argv)
 
     signal(SIGPIPE, SIG_IGN);
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_trace_opts);
diff --git a/util/qemu-error.c b/util/qemu-error.c
index fcbe8a1f74..db838e9f20 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -345,3 +345,36 @@ bool warn_report_once_cond(bool *printed, const char *fmt, ...)
     va_end(ap);
     return true;
 }
+
+static void qemu_log_func(const gchar *log_domain,
+                          GLogLevelFlags log_level,
+                          const gchar *message,
+                          gpointer user_data)
+{
+    switch (log_level & G_LOG_LEVEL_MASK) {
+    case G_LOG_LEVEL_DEBUG:
+        break;
+    case G_LOG_LEVEL_INFO:
+        /* Fall through */
+    case G_LOG_LEVEL_MESSAGE:
+        info_report("%s", message);
+        break;
+    case G_LOG_LEVEL_WARNING:
+        /* Fall through */
+    case G_LOG_LEVEL_CRITICAL:
+        warn_report("%s", message);
+        break;
+    case G_LOG_LEVEL_ERROR:
+        error_report("%s", message);
+        break;
+    }
+}
+
+/*
+ * Init QEMU logging subsystem. This sets up glib logging so libraries using it
+ * also print their logs through {info,warn,error}_report.
+ */
+void qemu_init_logging(void)
+{
+    g_log_set_default_handler(qemu_log_func, NULL);
+}
diff --git a/vl.c b/vl.c
index a5ae5f23d2..d986fd93ab 100644
--- a/vl.c
+++ b/vl.c
@@ -3015,6 +3015,7 @@ int main(int argc, char **argv, char **envp)
     QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue
         = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
 
+    qemu_init_logging();
     module_call_init(MODULE_INIT_TRACE);
 
     qemu_init_cpu_list();
