Enable the log feature of Open vSwitch in Linux for debugging and troubleshooting
I tried to deploy troubleshooting for my Open vSwitch. In view of this, I want to check its debugging information generated by the built-in log mechanism. How can I enable the log function of Open vSwitch and modify its log level (for example, to INFO/DEBUG level) to check more detailed debugging information?
Open vSwitch (OVS) is the most popular Open-source Virtual Switch on Linux. Because today's data centers are increasingly dependent on the SDN architecture, OVS is rapidly applied as a network element in the SDN deployment of data centers.
Open vSwitch has a built-in Log Mechanism, which is called VLOG. VLOG allows you to enable and customize logs in various network switching components. The log information generated by VLOG can be sent to a console, syslog, and a separate log file that is easy to view. You canovs-appctl
The command line tool for dynamic configuration of OVS logs at runtime.
Here we will show you how to useovs-appctl
Enable and customize the log function in Open vSwitch.
Below isovs-appctl
Custom VLOG syntax.
$ sudo ovs-appctl vlog/setmodule[:facility[:level]]
- Module: name of any valid component in OVS (such as netdev, ofproto, dpif, vswitchd, etc)
- Facility: log information destination (must be console, syslog, or file)
- Level: log details (must be emer, err, warn, info, or dbg)
In OVS source code, the module name is defined in the following format in the source file:
VLOG_DEFINE_THIS_MODULE(<module-name>);
For example, in lib/netdev. c, you can see:
VLOG_DEFINE_THIS_MODULE(netdev);
This indicates that lib/netdev. c is part of the netdev module, and any log information generated in lib/netdev. c will belong to the netdev module.
In OVS source code, multiple severity levels are used to define several different types of log information: VLOGINFO () for reporting, VLOGWARN () is used for warning, VLOGERR () is used for error message, VLOGDBG () is used for debugging information, and VLOG_EMERG is used for emergencies. Log Level and tool determine which log information is sent.
To view the complete list of available modules, tools, and their respective log levels, run the following command. This command must be called after you start OVS.
$ sudo ovs-appctl vlog/list
The output shows the debugging level of each module used in three scenarios (facility: console, syslog, file. By default, the log level of all modules is set to INFO.
Specify any OVS module, and you can selectively modify the debugging level for any specific scenario. For example, if you want to view more detailed debugging information of dpif on the console screen, you can run the following command.
$ sudo ovs-appctl vlog/set dpif:console:dbg
You will see that the dpif console tool has changed its log level to DBG, while the Log Level of syslog and file has not changed in the other two scenarios.
If you want to modify the log level of all modules, you can specify "ANY" as the module name. For example, the following command modifies the Log Level of the console of each module to DBG.
$ sudo ovs-appctl vlog/set ANY:console:dbg
At the same time, if you want to modify the log level of all three occasions at a time, you can specify "ANY" as the occasion name. For example, the following command modifies the log level of all scenarios of each module to DBG.
$ sudo ovs-appctl vlog/set ANY:ANY:dbg
Via: http://ask.xmodulo.com/enable-logging-open-vswitch.html
Author: Dan Nanni Translator: GOLinux Proofreader: wxy
This article was originally translated by LCTT and launched with the Linux honor in China
This article permanently updates the link address: