diff --git a/files/image_config/rsyslog/rsyslog.conf.j2 b/files/image_config/rsyslog/rsyslog.conf.j2 index c29d803d08..f6d4804940 100644 --- a/files/image_config/rsyslog/rsyslog.conf.j2 +++ b/files/image_config/rsyslog/rsyslog.conf.j2 @@ -107,7 +107,7 @@ $RepeatedMsgReduction on {% set regex = conf.get('filter_regex') -%} {% set fmodifier = '!' if filter == 'exclude' else '' %} -{% set device = 'eth0' if vrf == 'default' else vrf -%} +{% set device = vrf if vrf != '' and vrf != 'default' -%} {% set template = 'WelfRemoteFormat' if format == 'welf' else 'SONiCFileFormat' -%} {# Server extra options -#} @@ -115,11 +115,16 @@ $RepeatedMsgReduction on {% if source -%} {% set options = options ~ ' Address="' ~ source ~ '"'-%} + {% set device = device if device != 'eth0' else '' -%} +{% endif -%} + +{% if device -%} + {% set options = options ~ ' Device="' ~ device ~ '"'-%} {% endif -%} {% if filter %} :msg, {{ fmodifier }}ereregex, "{{ regex }}" {% endif %} *.{{ severity }} -action(type="omfwd" Target="{{ server }}" Port="{{ port }}" Protocol="{{ proto }}" Device="{{ device }}" Template="{{ template }}"{{ options }}) +action(type="omfwd" Target="{{ server }}" Port="{{ port }}" Protocol="{{ proto }}" Template="{{ template }}"{{ options }}) {% endfor %}