How to receive syslog messages and convert them to string

2.1k Views Asked by At

First I would like to receive the syslog message, the second I would like to syslog message into string type, please tell me how to write java code。

The following code can only be output in the console, how to get the string type of message.

SyslogServerEventHandlerIF eventHandler = new PrintStreamSyslogServerEventHandler(System.out);
SyslogServerIF serverIF = SyslogServer.getInstance("udp");
SyslogServerConfigIF config = serverIF.getConfig();
config.setHost("192.168.1.114");
config.setPort(10000);
config.addEventHandler(eventHandler);
serverIF.initialize("udp",config);
serverIF.run();
1

There are 1 best solutions below

0
Ayan On

You can use Apache-camel for receiving messages over UDP and then unmarshal using syslog dataformat. It supports both RFC3164 and RFC5424. REFER : http://camel.apache.org/syslog.html