<<Include(Debugging/Header)>>
||<tablestyle="float:right; font-size: 0.9em; width:30%; background:#F1F1ED; background-image: url('https://librarian.launchpad.net/1812570/bugsquad.png'); background-repeat: no-repeat; background-position:  98% 0.5ex; margin: 0 0 1em 1em; padding: 0.5em;"><<TableOfContents>>||

= Introduction =

As more and more applications and system services use D-Bus, it becomes more important to know how to see what happens on the bus.

There are two buses commonly used: the session bus and the system bus.  Either may be used by any application, depending on what it is doing.

= How to monitor the session bus =

This one is easy.  Just run dbus-monitor and watch the output.  This usually gives you enough information about what is happening on the bus.
{{{
dbus-monitor
}}}

= How to monitor the system bus =

This is trickier, because D-Bus policy typically prevents anything but signals from being viewable by dbus-monitor.  But we can change that.

 1. Create a file /etc/dbus-1/system-local.conf, with these contents:
 {{{
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
    <policy user="root">
        <allow eavesdrop="true"/>
        <allow eavesdrop="true" send_destination="*"/>
    </policy>
</busconfig>
 }}}
 1. Reboot your machine to pick up the configuration changes. Simply reloading the DBus server configuration is not sufficient. For further info see [[https://bugs.freedesktop.org/show_bug.cgi?id=80186|this bug]].

 1. Now run dbus-monitor as root.  You should be able to see all signals, method calls, and method replies.
 {{{
sudo dbus-monitor --system
 }}}
 1. When done debugging, it is wise to remove the policy snippet:
 {{{
sudo rm /etc/dbus-1/system-local.conf
 }}}

= Filtering all the noise =

If there is just too much information on the bus, pass a match rule like so:
{{{
dbus-monitor "type=signal,sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'"
}}}

Multiple rules can be specified.  If a message matches ''any'' of the rules, the message will be printed.  Like so:
{{{
dbus-monitor "type=error" "sender=org.freedesktop.SystemToolsBackends"
}}}
{{{
dbus-monitor "type=method_call" "type=method_return" "type=error"
}}}

See the [[http://dbus.freedesktop.org/doc/dbus-specification.html|D-Bus documentation]] for more information on match rule syntax.


----
CategoryBugSquad
CategoryDebugging