[libvirt] [PATCH 2/6] Save daemon logs to libvirtd.log

Daniel Veillard veillard at redhat.com
Thu Mar 3 13:49:29 UTC 2011


On Thu, Mar 03, 2011 at 11:38:19AM +0000, Daniel P. Berrange wrote:
> On Thu, Mar 03, 2011 at 06:22:13PM +0800, Daniel Veillard wrote:
> > 
> > Depending on whether it's run as root or user, the log is saved
> > in the local state dir or in $HOME/.libvirt. The file descriptor
> > is kept as a global variable used by following patches.
> > * daemon/libvirtd.c: add libvirtd.log as the output for logs
> > 
> > Signed-off-by: Daniel Veillard <veillard at redhat.com>
> > ---
> >  daemon/libvirtd.c |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++---
> >  1 files changed, 85 insertions(+), 5 deletions(-)
> 
> I don't think doing this is a good idea for a couple of reasons.
> First, I find that many people have already altered the libvirtd.conf
> file to log to /var/log/libvirtd.log by default instead of syslog.
> Second, when you have the log priority set to debug as this patch
> does, the logfile can get *VERY* large *VERY* quickly. eg, when

  Actually this patch doesn't change the log level. It the exact same
amount of noise as what's reaching syslog (by default).

> RHEV is using libvirt it is not uncommon to see  a 300 MB of logs
> generated in a mere 10 minutes, just from a fairly tightly targetted
> filter like '1:qemu 1:util 1:libvirt'. If we write all logs unfiltered
> at debug priority, then we will easily hit > 1 GB of data in < 10 mins.
> This patch isn't allowing admins any way to turn off this extra
> libvirtd.log in the cases where they are already collecting the data
> via a different log output.

  that's a valid point, yes

> I agree with the idea of having a dedicated libvirtd.log file by
> default though. So why don't we just change our default logging
> configuration to use a logfile, instead of syslog. eg change this
> block of code in libvirtd.c:
> 
>         if (godaemon) {
>             if (virAsprintf(&tmp, "%d:syslog:libvirtd",
>                             virLogGetDefaultPriority()) < 0)
>                 goto no_memory;
>         } else {
>             if (virAsprintf(&tmp, "%d:stderr",
>                             virLogGetDefaultPriority()) < 0)
>                 goto no_memory;
>         }
> 
> To be
> 
>         if (privileged) {
>             if (virAsprintf(&tmp, "%d:file:/var/log/libvirt/libvirtd.log",
>                         virLogGetDefaultPriority()) < 0)
>                 goto no_memory;
>         } else {
>            char *userdir = virGetUserDirectory(geteuid());
>            if (!userdir)
>               goto no_memory;
>            if (virAsprintf(&tmp, "%s/.libvirt/libvirtd.log", userdir) < 0) {
>               VIR_FRE(userdir);
>               goto no_memory;
>            }
>            VIR_FRE(userdir);
>         }
> 

  That sounds fine to me. I love syslog, but I find the current use an
abuse somehow, and since people can adjust, yes it sounds nicer to go
to a specific file instead.

> Thus people can just adjust 'log_debug' or 'log_filters' settings in
> libvirtd.conf if they want more verbose logging.

  Agreed,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list