提交 7022b091 编写于 作者: D Daniel P. Berrange

Automatically enable systemd journal logging

Probe to see if the systemd journal is accessible, and if
so enable logging to the journal by default, rather than
stderr (current default under systemd).
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 f6430390
......@@ -636,7 +636,21 @@ daemonSetupLogging(struct daemonConfig *config,
virLogParseOutputs(config->log_outputs);
/*
* If no defined outputs, then direct to libvirtd.log when running
* If no defined outputs, then first try to direct it
* to the systemd journal (if it exists)....
*/
if (virLogGetNbOutputs() == 0) {
char *tmp;
if (access("/run/systemd/journal/socket", W_OK) >= 0) {
if (virAsprintf(&tmp, "%d:journald", virLogGetDefaultPriority()) < 0)
goto no_memory;
virLogParseOutputs(tmp);
VIR_FREE(tmp);
}
}
/*
* otherwise direct to libvirtd.log when running
* as daemon. Otherwise the default output is stderr.
*/
if (virLogGetNbOutputs() == 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册