I want to parse syslog messages coming to a syslog server implemented in syslog4J. It is possible to do that in syslog4J?
What I want to do is to be able to segregate out various fields in syslog messages like hostname, timestamp, message, severity level etc. and make a uniform syslog pattern for future analysis.
This king of functionality is available in rsyslog or syslogNG.
SyslogServerConfigIF config = new TCPNetSyslogServerConfig("0.0.0.0", 1455);
config.setUseStructuredData(true);
SyslogServerIF syslogserver = SyslogServer.getInstance("tcp");
syslogserver.initialize("tcp", config);
syslogserver.run();
Start with creating a new Event Handler class to handle the messages. Note that the parsing should be done in the event() method as that will be called for each syslog event.
Finally register that new class as an EventHandler in the syslog4j config:
eventHandler = new SyslogMessageHandler(); config.addEventHandler(eventHandler);Then you are ready to start testing and debugging your various formats and patterns :)