diff --git a/src/util/virerror.c b/src/util/virerror.c index 3eb4f5d267..ae303d57a5 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -710,10 +710,19 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED, if (virErrorLogPriorityFilter) priority = virErrorLogPriorityFilter(to, priority); - virLogMessage(virErrorLogPriorityFilter ? VIR_LOG_FROM_FILE : VIR_LOG_FROM_ERROR, - priority, - filename, linenr, funcname, - meta, "%s", str); + /* We don't want to pollute stderr if no logging outputs + * are explicitly requested by the user, since the default + * error function already pollutes stderr and most apps + * hate & thus disable that too. If the daemon has set + * a priority filter though, we should always forward + * all errors to the logging code. + */ + if (virLogGetNbOutputs() > 0 || + virErrorLogPriorityFilter) + virLogMessage(VIR_LOG_FROM_ERROR, + priority, + filename, linenr, funcname, + meta, "%s", str); errno = save_errno; } diff --git a/src/util/virlog.c b/src/util/virlog.c index e9bd61b471..801f25952e 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -882,7 +882,7 @@ virLogVMessage(virLogSource source, str, msg, virLogOutputs[i].data); } } - if ((virLogNbOutputs == 0) && (source != VIR_LOG_FROM_ERROR)) { + if (virLogNbOutputs == 0) { if (logVersionStderr) { const char *rawver; char *ver = NULL;