diff --git a/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini b/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini index 349347a251..3262571206 100644 --- a/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini +++ b/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini @@ -51,6 +51,8 @@ root_helper = sudo # integration_bridge = br-int # [AGENT] # root_helper = sudo +# Add the following setting, if you want to log to a file +# log_file = /var/log/quantum/ovs_quantum_agent.log # # 2. With tunneling. # [DATABASE] diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index 9c94f9807b..a11f43e069 100755 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -523,6 +523,15 @@ def main(): config_file = args[0] conf = config.parse(config_file) + if conf.AGENT.log_file: + # Avoid to redirect traces to stdout/stderr + logging.getLogger().handlers = [] + handler = logging.FileHandler(conf.AGENT.log_file) + formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') + handler.setFormatter(formatter) + LOG.addHandler(handler) + LOG.debug('Verbose: %s', options.verbose) + # Determine which agent type to use. enable_tunneling = conf.OVS.enable_tunneling integ_br = conf.OVS.integration_bridge diff --git a/quantum/plugins/openvswitch/common/config.py b/quantum/plugins/openvswitch/common/config.py index c0f7680f63..88a5798807 100644 --- a/quantum/plugins/openvswitch/common/config.py +++ b/quantum/plugins/openvswitch/common/config.py @@ -34,6 +34,7 @@ ovs_opts = [ agent_opts = [ cfg.IntOpt('polling_interval', default=2), cfg.StrOpt('root_helper', default='sudo'), + cfg.StrOpt('log_file', default=None), ]