0

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();
Aaron
  • 1
  • 2
  • what have you done so far? – rkosegi Feb 23 '17 at 05:12
  • @rkosegi The above code can only be output in the console, how to get the string type of message – Aaron Feb 23 '17 at 05:20
  • this code seems to spawn syslog server. You want to receive message. confused. – rkosegi Feb 23 '17 at 05:22
  • @rkosegi This code is to receive the message and then print to the console, introducing the syslog.jar package. – Aaron Feb 23 '17 at 05:28
  • @rkosegi Because I want to parse the syslog message, so I want to get a String type of message first, and then use regular expressions to match – Aaron Feb 23 '17 at 05:30
  • @rkosegi I want to parse syslog messages coming to a syslog server implemented in syslog4J. – Aaron Feb 23 '17 at 05:52

1 Answers1

0

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

Ayan
  • 1