简体   繁体   English

如何接收系统日志消息并将其转换为字符串

[英]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。 首先我想收到系统日志消息,其次我想将系统日志消息转换为字符串类型,请告诉我如何编写Java代码。

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. 您可以使用Apache-camel通过UDP接收消息,然后使用syslog数据格式将其解组。 It supports both RFC3164 and RFC5424. 它同时支持RFC3164和RFC5424。 REFER : http://camel.apache.org/syslog.html 参考: http : //camel.apache.org/syslog.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使客户端服务器Java应用程序在一个端口上发送消息,而在另一个端口上接收消息? - How do I make a client-server Java application to send messages on one port but receive them on another? 如何使用log4j将错误和信息消息分别记录到syslog中? - How to log error and info messages separately into syslog with log4j? 如何使发布接收消息? - How to make the publish receive messages? 当我通过sprint-integration-syslog从syslog客户端收到消息时,如何获取远程地址? - how can I get the remote address when I receive message from syslog client by sprint-integration-syslog? 从 SQS 和 map 接收消息/事件到 Dynamodb - Receive messages/events from SQS and map them to Dynamodb 给定 ISO 和时区字符串,如何将它们转换为 Java 中的 UTC 字符串? - Given ISO and timezone strings, how to convert them to UTC string in Java? 如何接收来自特定号码的短信? - How to receive SMS messages from a specific number? 如何接收来自不同代理的消息 - How to receive messages from different Agents 如何在HiveMQ客户端中接收多条消息? (MQTT) - How to receive multiple messages in HiveMQ Client? (MQTT) 如何使用JMSTemplate和选择器从ActiveMQ接收消息? - How to receive messages from ActiveMQ with JMSTemplate and a selector?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM