[Translated]20150806 Linux FAQs with Answers--How to enable logging in Open vSwitch for debugging and troubleshooting.md

This commit is contained in:
GOLinux 2015-08-07 09:55:36 +08:00
parent 09b98f265e
commit cf1e4ef937
2 changed files with 69 additions and 70 deletions

View File

@ -1,70 +0,0 @@
Translating by GOlinu
Linux FAQs with Answers--How to enable logging in Open vSwitch for debugging and troubleshooting
================================================================================
> **Question:** I am trying to troubleshoot my Open vSwitch deployment. For that I would like to inspect its debug messages generated by its built-in logging mechanism. How can I enable logging in Open vSwitch, and change its logging level (e.g., to INFO/DEBUG level) to check more detailed debug information?
Open vSwitch (OVS) is the most popular open-source implementation of virtual switch on the Linux platform. As the today's data centers increasingly rely on the software-defined network (SDN) architecture, OVS is fastly adopted as the de-facto standard network element in data center's SDN deployments.
Open vSwitch has a built-in logging mechanism called VLOG. The VLOG facility allows one to enable and customize logging within various components of the switch. The logging information generated by VLOG can be sent to a combination of console, syslog and a separate log file for inspection. You can configure OVS logging dynamically at run-time with a command-line tool called `ovs-appctl`.
![](https://farm1.staticflickr.com/499/19300367114_cd8aac2fb2_c.jpg)
Here is how to enable logging and customize logging levels in Open vSwitch with `ovs-appctl`.
The syntax of `ovs-appctl` to customize VLOG is as follows.
$ sudo ovs-appctl vlog/set module[:facility[:level]]
- **Module**: name of any valid component in OVS (e.g., netdev, ofproto, dpif, vswitchd, and many others)
- **Facility**: destination of logging information (must be: console, syslog or file)
- **Level**: verbosity of logging (must be: emer, err, warn, info, or dbg)
In OVS source code, module name is defined in each source file in the form of:
VLOG_DEFINE_THIS_MODULE(<module-name>);
For example, in lib/netdev.c, you will see:
VLOG_DEFINE_THIS_MODULE(netdev);
which indicates that lib/netdev.c is part of netdev module. Any logging messages generated in lib/netdev.c will belong to netdev module.
In OVS source code, there are multiple severity levels used to define several different kinds of logging messages: VLOG_INFO() for informational, VLOG_WARN() for warning, VLOG_ERR() for error, VLOG_DBG() for debugging, VLOG_EMERG for emergency. Logging level and facility determine which logging messages are sent where.
To see a full list of available modules, facilities, and their respective logging levels, run the following commands. This command must be invoked after you have started OVS.
$ sudo ovs-appctl vlog/list
![](https://farm1.staticflickr.com/465/19734939478_7eb5d44635_c.jpg)
The output shows the debug levels of each module for three different facilities (console, syslog, file). By default, all modules have their logging level set to INFO.
Given any one OVS module, you can selectively change the debug level of any particular facility. For example, if you want to see more detailed debug messages of dpif module at the console screen, run the following command.
$ sudo ovs-appctl vlog/set dpif:console:dbg
You will see that dpif module's console facility has changed its logging level to DBG. The logging level of two other facilities, syslog and file, remains unchanged.
![](https://farm1.staticflickr.com/333/19896760146_5d851311ae_c.jpg)
If you want to change the logging level for all modules, you can specify "ANY" as the module name. For example, the following command will change the console logging level of every module to DBG.
$ sudo ovs-appctl vlog/set ANY:console:dbg
![](https://farm1.staticflickr.com/351/19734939828_8c7f59e404_c.jpg)
Also, if you want to change the logging level of all three facilities at once, you can specify "ANY" as the facility name. For example, the following command will change the logging level of all facilities for every module to DBG.
$ sudo ovs-appctl vlog/set ANY:ANY:dbg
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/enable-logging-open-vswitch.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://ask.xmodulo.com/author/nanni

View File

@ -0,0 +1,69 @@
Linux有问必答——如何启用Open vSwitch的日志功能以便调试和排障
================================================================================
> **问题** 我试着为我的Open vSwitch部署排障鉴于此我想要检查它的由内建日志机制生成的调试信息。我怎样才能启用Open vSwitch的日志功能并且修改它的日志等级修改成INFO/DEBUG级别以便于检查更多详细的调试信息呢
Open vSwitchOVS)是Linux平台上用于虚拟切换的最流行的开源部署。由于当今的数据中心日益依赖于软件定义的网络SDN架构OVS被作为数据中心的SDN部署中实际上的标准网络元素而快速采用。
Open vSwitch具有一个内建的日志机制它称之为VLOG。VLOG工具允许你在各种切换组件中启用并自定义日志由VLOG生成的日志信息可以被发送到一个控制台syslog以及一个独立日志文件组合以供检查。你可以通过一个名为`ovs-appctl`的命令行工具在运行时动态配置OVS日志。
![](https://farm1.staticflickr.com/499/19300367114_cd8aac2fb2_c.jpg)
这里为你演示如何使用`ovs-appctl`启用Open vSwitch中的日志功能并进行自定义。
下面是`ovs-appctl`自定义VLOG的语法。
$ sudo ovs-appctl vlog/set module[:facility[:level]]
- **Module**OVS中的任何合法组件的名称如netdevofprotodpifvswitchd以及其它大量组件
- **Facility**日志信息的目的地必须是consolesyslog或者file
- **Level**日志的详细程度必须是emererrwarninfo或者dbg
在OVS源代码中模块名称在源文件中是以以下格式定义的
VLOG_DEFINE_THIS_MODULE(<module-name>);
例如在lib/netdev.c中你可以看到
VLOG_DEFINE_THIS_MODULE(netdev);
这个表明lib/netdev.c是netdev模块的一部分任何在lib/netdev.c中生成的日志信息将属于netdev模块。
在OVS源代码中有多个严重度等级用于定义几个不同类型的日志信息VLOG_INFO()用于报告VLOG_WARN()用于警告VLOG_ERR()用于错误提示VLOG_DBG()用于调试信息VLOG_EMERG用于紧急情况。日志等级和工具确定哪个日志信息发送到哪里。
要查看可用模块、工具和各自日志级别的完整列表请运行以下命令。该命令必须在你启动OVS后调用。
$ sudo ovs-appctl vlog/list
![](https://farm1.staticflickr.com/465/19734939478_7eb5d44635_c.jpg)
输出结果显示了用于三个工具consolesyslogfile的各个模块的调试级别。默认情况下所有模块的日志等级都被设置为INFO。
指定任何一个OVS模块你可以选择性地修改任何特定工具的调试级别。例如如果你想要在控制台屏幕中查看dpif更为详细的调试信息可以运行以下命令。
$ sudo ovs-appctl vlog/set dpif:console:dbg
你将看到dpif模块的console工具已经将其日志等级修改为DBG而其它两个工具syslog和file的日志级别仍然没有改变。
![](https://farm1.staticflickr.com/333/19896760146_5d851311ae_c.jpg)
如果你想要修改所有模块的日志等级你可以指定“ANY”作为模块名。例如下面命令将修改每个模块的console的日志级别为DBG。
$ sudo ovs-appctl vlog/set ANY:console:dbg
![](https://farm1.staticflickr.com/351/19734939828_8c7f59e404_c.jpg)
同时如果你想要一次性修改所有三个工具的日志级别你可以指定“ANY”作为工具名。例如下面的命令将修改每个模块的所有工具的日志级别为DBG。
$ sudo ovs-appctl vlog/set ANY:ANY:dbg
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/enable-logging-open-vswitch.html
作者:[Dan Nanni][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://ask.xmodulo.com/author/nanni