I have coded a single program in spark to receive data from a local socket and capture lines that has the "Error" in them. I write manually in terminal:

$ nc -lk 9999
Error: some error message
Warning: some warning message

and so on. I need the socket get the system log information automatically. What ever log file in the system that contains Error messages or Warning ones and then my program can extract Error ones from the socket.

  • Your question in unclear. I understand that you want to forward all syslog messages with severity warning and worse to your socket. Is that true? For that you would configure your syslog daemon. What syslog daemon do you run? rsyslog?
    – PerlDuck
    May 17 '18 at 15:40
  • Yes, Exactly. and yes, rsyslog May 17 '18 at 15:42

You said you use rsyslogd. Then put a file (e.g. my-forward.conf) with the following content into /etc/rsyslog.d/:

if ( prifilt("*.warning") ) then {
    action(type="omfwd" protocol="tcp" target="" port="9999")

and restart the syslog daemon:

systemctl restart rsyslog

This will forward the syslog messages for all facilities with severity warning and worse via TCP to

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.