Problem Description:
Server B receives message gateway logs from Server A from the remote side, and according to the configuration requirements, these logs need to be written in different files according to the message label classification.
For example, there is a log:
Sep 08:00:03 192.100.6.3 monster-cmpp20mo[37518]: 20180912080002sms0000999l00100000000cc515275,0,00,,, 09120800018510260295,,,, xxxxxxxxxxx,,, 1,xxxxxxxxxx,,,,,,,,,,,, 0,6,dm302j,
We want to be able to write to the Monster-cmppmo.log file as a message label such as "Monster-cmpp20mo".
However, the effect of log filtering cannot be achieved by the previous configuration, and Server B writes all the logs it receives to each file. There is no sorting process at all.
Workaround:
Add a template First
" %timegenerated%%hostname%%syslogtag%%msg:::d rop-last-lf%\n " PS: drop-last-lf means write all logs
Once you have finished adding templates, you need to configure the template to use it.
if ' monster-cmpp20mt ' then {*.=info /xxx/xxx/monster-cmppmt.log; Traditionalformat}if'monster-mm7mt')then {*.=info /xxx/xxx/monster-mm7mt.log; Traditionalformat} ...
Restart Rsyslog to resolve.
Resolve Rsyslog Log Distribution filtering issues