<atitle="How and where to report bugs and request features"class="inactive"href="bugs.html">Bug reports</a>
</div>
</li><li>
<div>
<atitle="How to contact the developers via email and IRC"class="inactive"href="contact.html">Contact</a>
</div>
</li><li>
<div>
<atitle="Miscellaneous links of interest related to libvirt"class="inactive"href="relatedlinks.html">Related Links</a>
</div>
</li><li>
<div>
<atitle="Overview of all content on the website"class="inactive"href="sitemap.html">Sitemap</a>
</div>
</li></ul>
</div>
<divid="content">
<h1>Logging in the library and the daemon</h1>
<p>Libvirt includes logging facilities starting from version 0.6.0,
this complements the <ahref="errors.html">error handling</a>
mechanism and APIs to allow tracing though the execution of the
library as well as in the libvirtd daemon.</p>
<p>The logging functionalities in libvirt are based on 3 key concepts,
similar to the one present in other generic logging facilities like
log4j:</p>
<ul><li>log messages: they are information generated at runtime by
the libvirt code, it includes a priority level (DEBUG = 1,
INFO = 2, WARNING = 3, ERROR = 4), a category, function name and
line number, indicating where it originated from, and finally
a formatted message, in addition the library adds a timestamp
at the begining of the message</li><li>log filters: it's a set of patter and priorities allowing to acept
or reject a log message, if the message category matches a filter,
the message priority is compared to the filter priority, if lower
the message is discarded, if higher the message is output. If
no filter matches, then a general priority level is applied to
all remaining messages. This allows to capture for example all
debug messages for the QEmu driver, but otherwise only allow
errors to show up from other parts</li><li>log outputs: once a message has gone though filtering a set of
output defines where to send the message, they can also filter
based on the priority, for example it may be useful to output
all messages to a debugging file but only allow errors to be
logged though syslog.</li></ul>
<p>The library configuration of logging is though 3 environment variables
allowing to control the logging behaviour:</p>
<ul><li>LIBVIRT_DEBUG: it can take the four following values:
<ul><li>1 or "debug": asking the library to log every message emitted,
though the filters can be used to avoid filling up the output</li><li>2 or "info": log all non-debugging informations</li><li>3 or "warn": log warnings and errors, that's the default value</li><li>4 or "error": log only error messages</li></ul></li><li>LIBVIRT_LOG_FILTERS: allow to define logging filters</li><li>LIBVIRT_LOG_OUTPUTS: allow to define logging outputs</li></ul>
<p>Similary the daemon logging behaviour can be tuned using 3 config
<ul><li>4: only errors</li><li>3: warnings and errors</li><li>2: informations, warnings and errors</li><li>1: debug and everything</li></ul></li><li>log_filters: allow to define logging filters</li><li>log_outputs: allow to define logging outputs</li></ul>