mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Change default log policy to libvirtd.log instead of syslog
Syslog is not the best place to go search for libvirt error logs, change it to a default file output libvirtd.log, but still keep standard error if not run as a daemon. Depending on whether it's run as root or user, the log is saved in the local state dir or in $HOME/.libvirt. * daemon/libvirtd.c: change default logging to go to libvirtd.log
This commit is contained in:
parent
8b9a1190c1
commit
8ddf6d1e4e
@ -2698,16 +2698,18 @@ remoteReadSaslAllowedUsernameList (virConfPtr conf ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up the logging environment
|
* Set up the logging environment
|
||||||
* By default if daemonized all errors go to syslog and the logging
|
* By default if daemonized all errors go to the logfile libvirtd.log,
|
||||||
* is also saved onto the logfile libvird.log, but if verbose or error
|
* but if verbose or error debugging is asked for then also output
|
||||||
* debugging is asked for then output informations or debug.
|
* informations or debug.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
qemudSetLogging(virConfPtr conf, const char *filename)
|
qemudSetLogging(struct qemud_server *server, virConfPtr conf,
|
||||||
|
const char *filename)
|
||||||
{
|
{
|
||||||
int log_level = 0;
|
int log_level = 0;
|
||||||
char *log_filters = NULL;
|
char *log_filters = NULL;
|
||||||
char *log_outputs = NULL;
|
char *log_outputs = NULL;
|
||||||
|
char *log_file = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virLogReset();
|
virLogReset();
|
||||||
@ -2743,19 +2745,30 @@ qemudSetLogging(virConfPtr conf, const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If no defined outputs, then direct to syslog when running
|
* If no defined outputs, then direct to libvirtd.log when running
|
||||||
* as daemon. Otherwise the default output is stderr.
|
* as daemon. Otherwise the default output is stderr.
|
||||||
*/
|
*/
|
||||||
if (virLogGetNbOutputs() == 0) {
|
if (virLogGetNbOutputs() == 0) {
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
|
||||||
if (godaemon) {
|
if (godaemon) {
|
||||||
if (virAsprintf (&tmp, "%d:syslog:libvirtd",
|
if (server->privileged) {
|
||||||
virLogGetDefaultPriority()) < 0)
|
if (virAsprintf(&tmp, "%d:file:%s/log/libvirt/libvirtd.log",
|
||||||
goto free_and_fail;
|
virLogGetDefaultPriority(),
|
||||||
|
LOCALSTATEDIR) == -1)
|
||||||
|
goto out_of_memory;
|
||||||
|
} else {
|
||||||
|
char *userdir = virGetUserDirectory(geteuid());
|
||||||
|
if (!userdir)
|
||||||
|
goto free_and_fail;
|
||||||
|
|
||||||
|
if (virAsprintf(&tmp, "%d:file:%s/.libvirt/libvirtd.log",
|
||||||
|
virLogGetDefaultPriority(), userdir) == -1)
|
||||||
|
goto out_of_memory;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virAsprintf (&tmp, "%d:stderr",
|
if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
|
||||||
virLogGetDefaultPriority()) < 0)
|
goto out_of_memory;
|
||||||
goto free_and_fail;
|
|
||||||
}
|
}
|
||||||
virLogParseOutputs(tmp);
|
virLogParseOutputs(tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -2772,7 +2785,21 @@ qemudSetLogging(virConfPtr conf, const char *filename)
|
|||||||
free_and_fail:
|
free_and_fail:
|
||||||
VIR_FREE(log_filters);
|
VIR_FREE(log_filters);
|
||||||
VIR_FREE(log_outputs);
|
VIR_FREE(log_outputs);
|
||||||
|
VIR_FREE(log_file);
|
||||||
return(ret);
|
return(ret);
|
||||||
|
|
||||||
|
out_of_memory:
|
||||||
|
virReportOOMError();
|
||||||
|
goto free_and_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stop logging
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
qemudStopLogging(void)
|
||||||
|
{
|
||||||
|
virLogShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the config file if it exists.
|
/* Read the config file if it exists.
|
||||||
@ -2805,7 +2832,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
|
|||||||
/*
|
/*
|
||||||
* First get all the logging settings and activate them
|
* First get all the logging settings and activate them
|
||||||
*/
|
*/
|
||||||
if (qemudSetLogging(conf, filename) < 0)
|
if (qemudSetLogging(server, conf, filename) < 0)
|
||||||
goto free_and_fail;
|
goto free_and_fail;
|
||||||
|
|
||||||
GET_CONF_INT (conf, filename, listen_tcp);
|
GET_CONF_INT (conf, filename, listen_tcp);
|
||||||
@ -3369,6 +3396,6 @@ error:
|
|||||||
qemudCleanup(server);
|
qemudCleanup(server);
|
||||||
if (pid_file)
|
if (pid_file)
|
||||||
unlink (pid_file);
|
unlink (pid_file);
|
||||||
virLogShutdown();
|
qemudStopLogging();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user