Security and Technology Ramblings…

How to dump a text file to a remote syslog server.

Note: This is posted here because my brain will forget it.

save this to /usr/local/bin/remotenetlog


#!/usr/bin/perl
use Net::Syslog;
my $s=new Net::Syslog(Facility=>'local4',Priority=>'debug', SyslogHost=>'remote.syslogserver.ip');
while($line=<stdin>){
  $line=~s/\n|\r//g;
  $s->send("$line",Priority=>'info');
}
</stdin>

Then, just do this…

tail -f /path/to/log/file/log | /usr/local/bin/remotenetlog

Leave a Reply