I wish to log my webproxy logs, dhcp logs, dns logs and hotspot logs into 4 respective files. Currently I log specific topic i need to rsyslog using follwing expression:
:fromhost-ip,isequal,“[MikrotikIP]” /var/log/Mikrotik.log
with above i get topics logged into one Mikrotik.log file.
i want rsyslog to throw logs to:
/var/log/Webproxy.log
/var/log/Dns.log
/var/log/Hotspot.log
/var/log/Dhcp.log
I am no rsyslog expert, any advise on that will be really helpful.
First of all - tune your Mikrotik to be able to forward the logs to the remote syslog server (check Mikrotik’s firewall as well).
At the syslog side (in my case it was Ubuntu 16.04 with rsyslog 8.x) set up rsyslog to be able to accept the remote events. Add/uncomment at rsyslog.conf:
and the linux side rsyslog-produced log file is completely missing the topic and severity “pptp,ppp,error” part:
Nov 26 17:34:14 e1 <24760>: user Admin authentication failed
Nov 26 17:34:14 e1 <24761>: user Admin authentication failed
Nov 26 17:34:14 e1 <24759>: user Admin authentication failed
I’ve searched the forum and making it work seems to require some creativity
Further searching points to rsyslog templates and fields “host” for tags and “topic” for the actual logging label.
Maybe I’ll post it as a separate forum topic if no one answers here..
I am trying to emulate your recommendation, however I am confused about the parameters in the “if statement” - see below
what does the ($hostname,‘mtik-gw[0-9]+.example.com’) reference? My host name is Mikrotik but I am not sure what ‘mtik-gw[0-9] + example.com’ refers to? What does the whole if/then statement achieve. I am trying to understand. Thanks.
John
if re_match($hostname,'mtik-gw[0-9]+.example.com') or re_match($hostname,'gw[0-9]+.example.net')