Description

This article explains how to make customized logging for contrail-vrouter-agent log files. This is required when default logging does not yield enough information for troubleshooting.

Symptoms

There can be troubleshooting scenarios where contrail-vrouter-agent log files are needed for a longer duration of time. At the same time, the number of files are also needed to be rotated. This procedure is tested for CEN-3.X and CEN-4.X.

Solution

Below is the configuration which is needed to modify in contrail-vrouter-agent.conf. The modification is for the size of file, number of files which needs be rotated and the severity of logging.

contrail-vrouter-agent.conf file with additional log file parameters:

log_file <defines location of log file>
log_file_size <defines size of log file after which log file will be rotated, the value is in bytes>
log_files_count <number of log files which will be kept>
log_level <log severity level modify it to SYS_DEBUG or other desired log severity>

root@compute:~# cat /etc/contrail/contrail-vrouter-agent.conf 
#
# Vnswad configuration options
#

[CONTROL-NODE]
servers = 192.168.10.137:5269
# List of IPAdress:Port of control-node's separated by space.(Mandatory)
# servers=10.0.0.1:5269 10.0.0.2:5260 10.0.0.3:5260

[DEFAULT]
# Everything in this section is optional

# IP address and port to be used to connect to collector.
# Multiple IP:port strings separated by space can be provided
# collectors=127.0.0.1:8086 10.0.0.1:8086

# Agent mode : can be vrouter / tsn / tsn-no-forwarding / tor (default is vrouter)
# agent_mode=

# Aging time for flow-records in seconds
# flow_cache_timeout=0

# hostname= # Retrieved from gethostname() or `hostname -s` equivalent

# Http server port for inspecting vnswad state (useful for debugging)
# http_server_port=8085

# Category for logging. Default value is '*'
# log_category=

# Number of tx-buffers on pkt0 interface
# pkt0_tx_buffers=1000
#
# Measure delays in different queues
# measure_queue_delay=0
#
# Local log file name
log_file=/var/log/contrail/contrail-vrouter-agent.log
log_file_size=204800
log_files_count=10

# Log severity levels. Possible values are SYS_EMERG, SYS_ALERT, SYS_CRIT,
# SYS_ERR, SYS_WARN, SYS_NOTICE, SYS_INFO and SYS_DEBUG. Default is SYS_NOTICE
log_level=SYS_DEBUG
 

restart vrouter-agent:

root@compute:~# service contrail-vrouter-agent restart


10 log files with configured size are rotated for vrouter-agent:

root@compute:~# ls -lah /var/log/contrail/contrail-vrouter-a*
-rw-r--r-- 1 root root  70K Dec 16 21:59 /var/log/contrail/contrail-vrouter-agent.log
-rw-r--r-- 1 root root 201K Dec 16 21:37 /var/log/contrail/contrail-vrouter-agent.log.1
-rw-r--r-- 1 root root 201K Dec 16 14:35 /var/log/contrail/contrail-vrouter-agent.log.10
-rw-r--r-- 1 root root 201K Dec 16 20:35 /var/log/contrail/contrail-vrouter-agent.log.2
-rw-r--r-- 1 root root 201K Dec 16 19:33 /var/log/contrail/contrail-vrouter-agent.log.3
-rw-r--r-- 1 root root 201K Dec 16 18:31 /var/log/contrail/contrail-vrouter-agent.log.4
-rw-r--r-- 1 root root 201K Dec 16 17:29 /var/log/contrail/contrail-vrouter-agent.log.5
-rw-r--r-- 1 root root 201K Dec 16 16:27 /var/log/contrail/contrail-vrouter-agent.log.6
-rw-r--r-- 1 root root 201K Dec 16 15:25 /var/log/contrail/contrail-vrouter-agent.log.7
-rw-r--r-- 1 root root 201K Dec 16 14:35 /var/log/contrail/contrail-vrouter-agent.log.8
-rw-r--r-- 1 root root 201K Dec 16 14:35 /var/log/contrail/contrail-vrouter-agent.log.9

Debug level logs are also printed:

root@compute:~# grep -i debug /var/log/contrail/contrail-vrouter-agent.log* | head -n 2
/var/log/contrail/contrail-vrouter-agent.log.10:2020-12-16 Wed 14:35:09:621.161 EST  compute [Thread 139850072151808, Pid 112721]: TCP [SYS_DEBUG]: TcpServerMessageLog: Server 0.0.0.0:8097  Initialization complete controller/src/io/tcp_server.cc 120
/var/log/contrail/contrail-vrouter-agent.log.10:2020-12-16 Wed 14:35:09:621.814 EST  compute [Thread 139850234464128, Pid 112721]: TCP [SYS_DEBUG]: TcpSessionMessageLog: Session 127.0.0.1:42354::127.0.0.1:20914 < Active session connection complete controller/src/io/tcp_session.cc 289