How to forward specific log file outside of /var/log with rsyslog to remote server?
772
How can I forward message from a specific log file like /www/myapp/log/test.log with rsyslog client to remote rsyslog server? This log file is outside of the directory /var/log.
This watches a file and saves to the local3 facility in syslog. Then you can send all data from the local3 facility to your remote server. You may also want to add the following to your rsyslog conf (usually /etc/rsyslog.d/50-default.conf on Ubuntu) to not save the local3 facility to /var/log/syslog:
Just setup an imfile rule in your /etc/rsyslog.conf
This watches a file and saves to the local3 facility in syslog. Then you can send all data from the local3 facility to your remote server. You may also want to add the following to your rsyslog conf (usually /etc/rsyslog.d/50-default.conf on Ubuntu) to not save the local3 facility to /var/log/syslog:
Additionally, I would encourage some reading from the following rsyslog docs for more advanced filtering:
On ubuntu, I had to also comment out the drop privileges lines in order to get the rsyslog to actually read the log file outside of /var/logs.