Package org.productivity.java.syslog4j.server

Examples of org.productivity.java.syslog4j.server.SyslogServerEventIF


     * Parses {@link Rfc5424SyslogEvent} instance from given raw message bytes and sends it to event handlers.
     *
     * @param rawMsg
     */
    private void handleSyslogMessage(final byte[] rawMsg) {
        final SyslogServerEventIF event = new Rfc5424SyslogEvent(rawMsg, 0, rawMsg.length);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Firing Syslog event: " + event);
        }
        final List eventHandlers = this.server.getConfig().getEventHandlers();
        for (int i = 0; i < eventHandlers.size(); i++) {
View Full Code Here


        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);
                }
View Full Code Here

        queue.clear();
        makeLogs(deployementUrl);
        for (Level level : LoggingServlet.LOG_LEVELS) {
            testLog(level);
        }
        final SyslogServerEventIF expectNoOtherMsg = queue.poll(3 * ADJUSTED_SECOND, TimeUnit.MILLISECONDS);
        Assert.assertNull("No other message was expected in syslog.", expectNoOtherMsg);
    }
View Full Code Here

        setSyslogAttribute("level", "ERROR");
        queue.clear();
        makeLogs(deployementUrl);
        testLog(Level.ERROR);
        testLog(Level.FATAL);
        final SyslogServerEventIF expectNoOtherMsg = queue.poll(3 * ADJUSTED_SECOND, TimeUnit.MILLISECONDS);
        Assert.assertNull("No other message was expected in syslog.", expectNoOtherMsg);
    }
View Full Code Here

        setSyslogAttribute("level", "TRACE");
        setSyslogAttribute(ENABLED, "false");
        queue.clear();
        try {
            makeLogs(deployementUrl);
            final SyslogServerEventIF expetNoMsg = queue.poll(5 * ADJUSTED_SECOND, TimeUnit.MILLISECONDS);
            Assert.assertNull("No syslog message expected.", expetNoMsg);
        } finally {
            setSyslogAttribute(ENABLED, "true");
        }
    }
View Full Code Here

     *
     * @param expectedLevel
     * @throws Exception
     */
    private void testLog(final Logger.Level expectedLevel) throws Exception {
        SyslogServerEventIF log = BlockedSyslogServerEventHandler.getQueue().poll(15 * ADJUSTED_SECOND, TimeUnit.MILLISECONDS);
        assertNotNull(log);
        assertEquals("Message with unexpected Syslog event level received.", getSyslogLevel(expectedLevel), log.getLevel());
        final String expectedMsg = MessageFormat.format(LoggingServlet.MSG_TEMPLATE, LoggingServlet.getPrefix(LOG_PREFIX),
                LoggingServlet.getLevelStr(expectedLevel));
        String msg = log.getMessage();
        assertEquals("Message with unexpected Syslog event text received.", expectedMsg, msg);
    }
View Full Code Here

TOP

Related Classes of org.productivity.java.syslog4j.server.SyslogServerEventIF

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.