Java Code Examples for org.productivity.java.syslog4j.SyslogConstants#SYSLOG_BUFFER_SIZE
The following examples show how to use
org.productivity.java.syslog4j.SyslogConstants#SYSLOG_BUFFER_SIZE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UDPSyslogServer.java From simple-syslog-server with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void run() { this.shutdown = false; try { this.ds = createDatagramSocket(); } catch (Exception e) { System.err.println("Creating DatagramSocket failed"); e.printStackTrace(); throw new SyslogRuntimeException(e); } byte[] receiveData = new byte[SyslogConstants.SYSLOG_BUFFER_SIZE]; while (!this.shutdown) { try { final DatagramPacket dp = new DatagramPacket(receiveData, receiveData.length); this.ds.receive(dp); final SyslogServerEventIF event = new Rfc5424SyslogEvent(receiveData, dp.getOffset(), dp.getLength()); System.out.println(">>> Syslog message came: " + event); } catch (SocketException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } }
Example 2
Source File: UDPSyslogServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void run() { this.shutdown = false; try { this.ds = createDatagramSocket(); } catch (Exception e) { LOGGER.error("Creating DatagramSocket failed", e); throw new SyslogRuntimeException(e); } byte[] receiveData = new byte[SyslogConstants.SYSLOG_BUFFER_SIZE]; while (!this.shutdown) { try { final DatagramPacket dp = new DatagramPacket(receiveData, receiveData.length); this.ds.receive(dp); final SyslogServerEventIF event = new Rfc5424SyslogEvent(receiveData, dp.getOffset(), dp.getLength()); List list = this.syslogServerConfig.getEventHandlers(); for (int i = 0; i < list.size(); i++) { SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) list.get(i); eventHandler.event(this, event); } } catch (SocketException se) { LOGGER.warn("SocketException occurred", se); } catch (IOException ioe) { LOGGER.warn("IOException occurred", ioe); } } }