QEMU and KVM virtual machines often run critical workloads where tracking activity and diagnosing issues is crucial. Enabling logging allows you to capture detailed information about VM operations, errors, and performance, making troubleshooting and auditing more effective. Configuring logging for QEMU/KVM VMs can be accomplished through command-line options or by adjusting libvirt configurations, depending on your virtualization setup.
Enable QEMU/KVM Logging via Command-Line Options
-D /path/to/qemu.log -d guest_errors options to your QEMU command. The -D flag specifies the log file location, and -d sets the type of debugging output you want (e.g., guest_errors, cpu, int, etc.). For example:qemu-system-x86_64 -hda /var/lib/libvirt/images/vm.img -m 2048 -D /var/log/qemu-vm.log -d guest_errors
This command will create a log file at /var/log/qemu-vm.log containing guest error messages.
-d option to include additional logging categories if needed. For a full list of debug options, run:qemu-system-x86_64 -d help
This will display all available logging categories, allowing you to tailor the log output to your troubleshooting needs.
Join readers who trust AllThings.How
Add us as a preferred source on Google so our practical guides show up first next time you search.
Add to Google Preferences →Enable Logging in Libvirt-Managed VMs
/etc/libvirt/. For system-wide logging, edit /etc/libvirt/qemu.conf.qemu.conf and set the following options to define log file location and verbosity:
# Enable logging for all QEMU VMs managed by libvirt
log_outputs="1:file:/var/log/libvirt/qemu/VMNAME.log"
log_filters="1:qemu"
Replace VMNAME with your specific VM’s name. The log_outputs option sets the log destination, and log_filters adjusts what is logged. You may need to create the log directory and set appropriate permissions.
sudo systemctl restart libvirtd
Capture VM Serial Console Output
-serial file:/var/log/qemu-serial.log
This will direct all serial console output to /var/log/qemu-serial.log, which is helpful for capturing kernel messages and early boot issues.
Enabling logging on QEMU/KVM VMs improves your ability to track, diagnose, and resolve issues quickly. Review your log files regularly and adjust settings as needed for optimal visibility and performance.






