翻译:libvirt :debug and logging

译libvirt : debug and logging

需要使用libvirt部分功能启动虚拟机,但是有需要qemu打印log。libvirt给出了相应的解决办法:

  • LIBVIRT_DEBUG
  • LIBVIRT_LOG_FILTERS
  • LIBVIRT_LOG_OUTPUTS

Markdown及扩展

libvirt中的日志记录设施基于3个关键概念。

变量
Log messages DEBUG = 1, INFO = 2, WARNING = 3, ERROR = 4
Log filters x:name
Log outputs filename

log messages代表日志等级,仅输出日志等级高于设置等级的信息

    1 (or debug) - log all messages
    2 (or info) - log all non-debugging information
    3 (or warn) - log only warnings and errors - this is the default
    4 (or error) - log only errors 

log filters 表示日志输出内容相关

1:qemu //输出qemu相关的调试信息,日志等级为debug

log outputs 表示输出路径

x:stderr - log to stderr
x:syslog:name - log to syslog with a prefix of "name"
x:file:file_path - log to a file specified by "file_path"

例子
LIBVIRT_DEBUG=error LIBVIRT_LOG_FILTERS=”1:qemu” LIBVIRT_LOG_OUTPUTS=”/var/log/libvirt/qemu/ubuntu12.log” virsh start ubuntu12
解析:
启动Ubuntu2 虚拟机,启用log输出:输出virsh error等级以上的信息,并将qemu debug 等级以上的信息输出至/var/log/libvirt/qemu/ubuntu12.log文件

猜你喜欢

转载自blog.csdn.net/ggg_xxx/article/details/80060672