提交 30727583 编写于 作者: E Erik Skultety

util: Fix the default log output to 'journald' when running under systemd

Essentially, bring back the old behaviour as of commit eba36a38 which
was later changed by commit ae06048b. Even though all the stderr
messages will eventually end up in the journal, we're not making use of
the fields journald provides.

https://bugzilla.redhat.com/show_bug.cgi?id=1592644Signed-off-by: NErik Skultety <eskultet@redhat.com>
Acked-by: NMichal Privoznik <mprivozn@redhat.com>
上级 f3a4fbd2
......@@ -223,11 +223,17 @@ virLogSetDefaultOutputToFile(const char *filename, bool privileged)
int
virLogSetDefaultOutput(const char *filename, bool godaemon, bool privileged)
{
if (!godaemon)
return virLogSetDefaultOutputToStderr();
bool have_journald = access("/run/systemd/journal/socket", W_OK) >= 0;
if (godaemon) {
if (have_journald)
return virLogSetDefaultOutputToJournald();
} else {
if (!isatty(STDIN_FILENO) && have_journald)
return virLogSetDefaultOutputToJournald();
if (access("/run/systemd/journal/socket", W_OK) >= 0)
return virLogSetDefaultOutputToJournald();
return virLogSetDefaultOutputToStderr();
}
return virLogSetDefaultOutputToFile(filename, privileged);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册