简体   繁体   中英

How to receive syslog messages and convert them to string

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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM