1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
5
This file is autogenerated from logging.html.in
6
Do not edit this file. Changes will be lost.
9
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
10
<link rel="stylesheet" type="text/css" href="main.css" />
11
<link rel="SHORTCUT ICON" href="32favicon.png" />
12
<title>libvirt: Logging in the library and the daemon</title>
13
<meta name="description" content="libvirt, virtualization, virtualization API" />
17
<div id="headerLogo"></div>
18
<div id="headerSearch">
19
<form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><div>
20
<input id="query" name="query" type="text" size="12" value="" />
21
<input id="submit" name="submit" type="submit" value="Search" />
29
<a title="Front page of the libvirt website" class="inactive" href="index.html">Home</a>
33
<a title="Details of new features and bugs fixed in each release" class="inactive" href="news.html">News</a>
37
<a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
41
<a title="Information for users, administrators and developers" class="active" href="docs.html">Documentation</a>
44
<a title="Information about deploying and using libvirt" class="active" href="deployment.html">Deployment</a>
47
<a title="The URI formats used for connecting to libvirt" class="inactive" href="uri.html">URI format</a>
51
<a title="Enable remote access over TCP" class="inactive" href="remote.html">Remote access</a>
55
<a title="Configure authentication for the libvirt daemon" class="inactive" href="auth.html">Authentication</a>
59
<a title="Access the libvirt daemon from a native Windows client" class="inactive" href="windows.html">Windows port</a>
63
<span class="active">Logging</span>
69
<a title="Overview of the logical subsystems in the libvirt API" class="inactive" href="intro.html">Architecture</a>
73
<a title="Description of the XML formats used in libvirt" class="inactive" href="format.html">XML format</a>
77
<a title="Hypervisor specific driver information" class="inactive" href="drivers.html">Drivers</a>
81
<a title="Reference manual for the C public API" class="inactive" href="html/index.html">API reference</a>
85
<a title="Bindings of the libvirt API for other languages" class="inactive" href="bindings.html">Language bindings</a>
91
<a title="User contributed content" class="inactive" href="http://wiki.libvirt.org">Wiki</a>
95
<a title="Frequently asked questions" class="inactive" href="FAQ.html">FAQ</a>
99
<a title="How and where to report bugs and request features" class="inactive" href="bugs.html">Bug reports</a>
103
<a title="How to contact the developers via email and IRC" class="inactive" href="contact.html">Contact</a>
107
<a title="Miscellaneous links of interest related to libvirt" class="inactive" href="relatedlinks.html">Related Links</a>
111
<a title="Overview of all content on the website" class="inactive" href="sitemap.html">Sitemap</a>
116
<h1>Logging in the library and the daemon</h1>
117
<p>Libvirt includes logging facilities starting from version 0.6.0,
118
this complements the <a href="errors.html">error handling</a>
119
mechanism and APIs to allow tracing though the execution of the
120
library as well as in the libvirtd daemon.</p>
121
<p>The logging functionalities in libvirt are based on 3 key concepts,
122
similar to the one present in other generic logging facilities like
124
<ul><li>log messages: they are information generated at runtime by
125
the libvirt code, it includes a priority level (DEBUG = 1,
126
INFO = 2, WARNING = 3, ERROR = 4), a category, function name and
127
line number, indicating where it originated from, and finally
128
a formatted message, in addition the library adds a timestamp
129
at the begining of the message</li><li>log filters: it's a set of patter and priorities allowing to acept
130
or reject a log message, if the message category matches a filter,
131
the message priority is compared to the filter priority, if lower
132
the message is discarded, if higher the message is output. If
133
no filter matches, then a general priority level is applied to
134
all remaining messages. This allows to capture for example all
135
debug messages for the QEmu driver, but otherwise only allow
136
errors to show up from other parts</li><li>log outputs: once a message has gone though filtering a set of
137
output defines where to send the message, they can also filter
138
based on the priority, for example it may be useful to output
139
all messages to a debugging file but only allow errors to be
140
logged though syslog.</li></ul>
141
<p>The library configuration of logging is though 3 environment variables
142
allowing to control the logging behaviour:</p>
143
<ul><li>LIBVIRT_DEBUG: it can take the four following values:
144
<ul><li>1 or "debug": asking the library to log every message emitted,
145
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>
146
<p>Similary the daemon logging behaviour can be tuned using 3 config
147
variables, stored in the configuration file:
149
<ul><li>log_level: accepts the following values:
150
<ul><li>0: no logging at all</li><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>
151
<p>In both case the syntax for filters and outputs is similar.</p>
152
<p>The format for a filter is:</p>
154
<p>where <code>name</code> is a match string e.g. <code>remote</code> or
155
<code>qemu</code> and the x is the minimal level where matching messages
156
should be logged:</p>
157
<ul><li>1: DEBUG</li><li>2: INFO</li><li>3: WARNING</li><li>4: ERROR</li></ul>
158
<p>Multiple filter can be defined in a single string, they just need to be
159
separated by spaces, e.g: <code>"3:remote 4:event"</code> to only get
160
warning or errors from the remote layer and only errors from the event
164
<p>The format for an output can be one of those 3 forms:</p>
165
<ul><li><code>x:stderr</code> output goes to stderr</li><li><code>x:syslog:name</code> use syslog for the output and use the
166
given <code>name</code> as the ident</li><li><code>x:file:file_path</code>output to a file, with the given
168
<p>In all cases the x prefix is the minimal level, acting as a filter:</p>
169
<ul><li>0: everything</li><li>1: DEBUG</li><li>2: INFO</li><li>3: WARNING</li><li>4: ERROR</li></ul>
170
<p>Multiple output can be defined , they just need to be separated by
171
spaces, e.g.: <code>"3:syslog:libvirtd 0:file:/tmp/libvirt.log"</code>
172
will log all warnings and errors to syslog under the libvirtd ident
173
but also log everything debugging and informations included in the
174
file <code>/tmp/libvirt.log</code></p>
175
<p>For example setting up the following:</p>
176
<pre>export LIBVIRT_DEBUG=1
177
export LIBVIRT_LOG_OUTPUTS="0:file:virsh.log"</pre>
178
<p>and then running virsh will accumulate the logs in the
179
<code>virsh.log</code> file in a way similar to:</p>
180
<pre>14:29:04.771: debug : virInitialize:278 : register drivers
181
14:29:04.771: debug : virRegisterDriver:618 : registering Test as driver 0</pre>
182
<p>the messages are timestamped, there is also the level recorded,
183
if debug the name of the function is also printed and then the formatted
184
message. This should be sufficient to at least get a precise idea of
185
what is happening and where things are going wrong, allowing to then
186
put the correct breakpoints when running under a debugger.</p>
191
Sponsored by:<br /><a href="http://et.redhat.com/"><img src="et.png" alt="Project sponsored by Red Hat Emerging Technology" /></a></p>