org.productivity.java.syslog4j.SyslogConstants Java Examples

The following examples show how to use org.productivity.java.syslog4j.SyslogConstants. 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 vote down vote up
@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: SyslogServer.java    From syslog4j with GNU Lesser General Public License v2.1 6 votes vote down vote up
public synchronized static final void destroyInstance(String protocol) {
	if (protocol == null || "".equals(protocol.trim())) {
		return;
	}

	String _protocol = protocol.toLowerCase();
	
	if (instances.containsKey(_protocol)) {
		SyslogUtility.sleep(SyslogConstants.THREAD_LOOP_INTERVAL_DEFAULT);
		
		SyslogServerIF syslogServer = (SyslogServerIF) instances.get(_protocol);

		try {
			syslogServer.shutdown();
			
		} finally {
			instances.remove(_protocol);
		}
		
	} else {
		throwRuntimeException("Cannot destroy server protocol \"" + protocol + "\" instance; call shutdown instead");
		return;
	}
}
 
Example #3
Source File: SyslogServer.java    From syslog4j with GNU Lesser General Public License v2.1 6 votes vote down vote up
public synchronized static final void destroyInstance(SyslogServerIF syslogServer) {
	if (syslogServer == null) {
		return;
	}
	
	String protocol = syslogServer.getProtocol().toLowerCase();
	
	if (instances.containsKey(protocol)) {
		SyslogUtility.sleep(SyslogConstants.THREAD_LOOP_INTERVAL_DEFAULT);
		
		try {
			syslogServer.shutdown();
			
		} finally {
			instances.remove(protocol);
		}
		
	} else {
		throwRuntimeException("Cannot destroy server protocol \"" + protocol + "\" instance; call shutdown instead");
	}
}
 
Example #4
Source File: SyslogParameterTest.java    From syslog4j with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testSequentialSyslogMessageModifierConfigCreate() {
	SequentialSyslogMessageModifierConfig config = new SequentialSyslogMessageModifierConfig();
	
	assertEquals(SyslogConstants.CHAR_SET_DEFAULT,config.getCharSet());
	config.setCharSet("Unicode");
	assertEquals("Unicode",config.getCharSet());
	
	config.setFirstNumber(500);
	assertEquals(config.getFirstNumber(),500);

	config.setLastNumber(1000);
	assertEquals(config.getLastNumber(),1000);

	config.setLastNumber(499);
	assertEquals(config.getLastNumber(),1000);
	
	config.setFirstNumber(1001);
	assertEquals(config.getFirstNumber(),500);
}
 
Example #5
Source File: TCPNetSyslogServer.java    From syslog4j with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void initialize() throws SyslogRuntimeException {
	this.tcpNetSyslogServerConfig = null;
	
	try {
		this.tcpNetSyslogServerConfig = (TCPNetSyslogServerConfigIF) this.syslogServerConfig;
		
	} catch (ClassCastException cce) {
		throw new SyslogRuntimeException("config must be of type TCPNetSyslogServerConfig");
	}
	
	if (this.syslogServerConfig == null) {
		throw new SyslogRuntimeException("config cannot be null");
	}

	if (this.tcpNetSyslogServerConfig.getBacklog() < 1) {
		this.tcpNetSyslogServerConfig.setBacklog(SyslogConstants.SERVER_SOCKET_BACKLOG_DEFAULT);
	}
}
 
Example #6
Source File: ReconnectSyslogServerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setupContainer() throws Exception {
    container.start();
    host = CoreUtils.stripSquareBrackets(TestSuiteEnvironment.getServerAddress());
    final JavaArchive deployment = createDeployment();
    deploy(deployment);
    SyslogServer.shutdown();
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.UDP);
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.TCP);
    startSyslogServers(host);
    setupServer();
}
 
Example #7
Source File: SyslogParameterTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testPooledSSLTCPNetSyslogConfigCreate() {
	PooledTCPNetSyslogConfig config = null;
	
	config = new PooledSSLTCPNetSyslogConfig();
	assertTrue(config.getSyslogWriterClass() == SSLTCPNetSyslogWriter.class);

	config = new PooledSSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH);
	assertTrue(config.getSyslogClass() == SSLTCPNetSyslog.class);
	assertEquals(SyslogConstants.FACILITY_AUTH,config.getFacility());

	config = new PooledSSLTCPNetSyslogConfig("hostname0");
	assertEquals("hostname0",config.getHost());
	config.setHost("hostname1");
	assertEquals("hostname1",config.getHost());

	config = new PooledSSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname2");
	assertEquals("hostname2",config.getHost());

	config = new PooledSSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname3",2222);
	assertEquals("hostname3",config.getHost());
	assertEquals(2222,config.getPort());
	config.setPort(3333);
	assertEquals(3333,config.getPort());

	config = new PooledSSLTCPNetSyslogConfig("hostname4",4444);
	assertEquals("hostname4",config.getHost());
	assertEquals(4444,config.getPort());
	
	testPoolConfig(config);
}
 
Example #8
Source File: SyslogParameterTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testSyslog4jBackLogHandler() {
	SyslogIF udp = Syslog.getInstance("udp");
	SyslogIF tcp = Syslog.getInstance("tcp");
	
	SyslogBackLogHandlerIF syslog4j = new Syslog4jBackLogHandler("udp");
	syslog4j.initialize();
	
	syslog4j.log(tcp,SyslogConstants.LEVEL_INFO,"Log4j BackLog Test Message - IGNORE","really");
	syslog4j.log(tcp,-1,"Log4j BackLog Test Message - IGNORE","really");
	syslog4j.down(tcp,null);
	syslog4j.up(tcp);

	syslog4j = new Syslog4jBackLogHandler("udp",false);
	
	syslog4j.log(tcp,SyslogConstants.LEVEL_INFO,"Log4j BackLog Test Message - IGNORE","really");
	syslog4j.log(tcp,-1,"Log4j BackLog Test Message - IGNORE","really");
	syslog4j.down(udp,null);
	syslog4j.up(udp);

	syslog4j = new Syslog4jBackLogHandler(udp);
	
	syslog4j.log(tcp,SyslogConstants.LEVEL_INFO,"Log4j BackLog Test Message - IGNORE","really");
	syslog4j.log(tcp,-1,"Log4j BackLog Test Message - IGNORE","really");
	
	syslog4j = new Syslog4jBackLogHandler(udp,false);
	
	syslog4j.log(tcp,SyslogConstants.LEVEL_INFO,"Log4j BackLog Test Message - IGNORE","really");
	syslog4j.log(tcp,-1,"Log4j BackLog Test Message - IGNORE","really");
	
	try {
		syslog4j.log(Syslog.getInstance("udp"),SyslogConstants.LEVEL_INFO,"Log4j BackLog Test Message - IGNORE","really");
		fail();
		
	} catch (SyslogRuntimeException sre) {
		//
	}
}
 
Example #9
Source File: SyslogParameterTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testPooledTCPNetSyslogConfigCreate() {
	PooledTCPNetSyslogConfig config = null;
	
	config = new PooledTCPNetSyslogConfig();
	assertTrue(config.getSyslogWriterClass() == TCPNetSyslogWriter.class);

	config = new PooledTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH);
	assertTrue(config.getSyslogClass() == PooledTCPNetSyslog.class);
	assertEquals(SyslogConstants.FACILITY_AUTH,config.getFacility());

	config = new PooledTCPNetSyslogConfig("hostname0");
	assertEquals("hostname0",config.getHost());
	config.setHost("hostname1");
	assertEquals("hostname1",config.getHost());

	config = new PooledTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname2");
	assertEquals("hostname2",config.getHost());

	config = new PooledTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname3",2222);
	assertEquals("hostname3",config.getHost());
	assertEquals(2222,config.getPort());
	config.setPort(3333);
	assertEquals(3333,config.getPort());

	config = new PooledTCPNetSyslogConfig("hostname4",4444);
	assertEquals("hostname4",config.getHost());
	assertEquals(4444,config.getPort());
	
	testPoolConfig(config);
}
 
Example #10
Source File: MaxQueueSizeTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testMaxQueueSize() {
	int catchCount = 5;
	int maxQueueSize = 5;
	int messagesToSend = 15;
	int port = 7777;
	
	FakeSyslogServer server = new FakeSyslogServer(port,catchCount);
	Thread thread = new Thread(server);
	thread.start();
	
	BackLogCounter counter = new BackLogCounter();
	
	TCPNetSyslogConfigIF syslogConfig = new TCPNetSyslogConfig();
	syslogConfig.setPort(port);
	assertEquals(syslogConfig.getMaxQueueSize(),SyslogConstants.MAX_QUEUE_SIZE_DEFAULT);
	syslogConfig.setMaxQueueSize(maxQueueSize);
	syslogConfig.addBackLogHandler(counter);
	syslogConfig.addBackLogHandler(NullSyslogBackLogHandler.INSTANCE);
	
	SyslogIF syslog = Syslog.createInstance("maxQueueSizeTest",syslogConfig);
	
	for(int i=1; i<=messagesToSend; i++) {
		syslog.log(SyslogConstants.LEVEL_INFO,"test line " + i);
	}
	
	SyslogUtility.sleep(500);
	
	server.shutdown = true;

	SyslogUtility.sleep(500);

	System.out.println("Sent Messages:       " + messagesToSend);	
	System.out.println("Received Messages:   " + server.count);
	System.out.println("Backlogged Messages: " + counter.count);
	
	assertEquals(messagesToSend,(server.count+counter.count));
}
 
Example #11
Source File: TCPNetSyslogWriter.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public synchronized void shutdown() throws SyslogRuntimeException {
	this.shutdown = true;
	
	if (this.syslogConfig.isThreaded()) {
		long timeStart = System.currentTimeMillis();
		boolean done = false;
		
		while(!done) {
			if (this.socket == null || this.socket.isClosed()) {
				done = true;
				
			} else {
				long now = System.currentTimeMillis();
				
				if (now > (timeStart + this.tcpNetSyslogConfig.getMaxShutdownWait())) {
					closeSocket(this.socket);
					this.thread.interrupt();
					done = true;
				}
				
				if (!done) {
					SyslogUtility.sleep(SyslogConstants.SHUTDOWN_INTERVAL);
				}
			}
		}
		
	} else {
		if (this.socket == null || this.socket.isClosed()) {
			return;
		}
		
		closeSocket(this.socket);
	}
}
 
Example #12
Source File: UDPSyslogServer.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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);
        }
    }
}
 
Example #13
Source File: SyslogHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Convert JBoss Logger.Level to Syslog log level.
 *
 * @param jbossLogLevel
 *
 * @return
 */
private int getSyslogLevel(Level jbossLogLevel) {
    final int result;
    switch (jbossLogLevel) {
        case TRACE:
        case DEBUG:
            result = SyslogConstants.LEVEL_DEBUG;
            break;
        case INFO:
            result = SyslogConstants.LEVEL_INFO;
            break;
        case WARN:
            result = SyslogConstants.LEVEL_WARN;
            break;
        case ERROR:
            result = SyslogConstants.LEVEL_ERROR;
            break;
        case FATAL:
            result = SyslogConstants.LEVEL_EMERGENCY;
            break;
        default:
            // unexpected
            result = SyslogConstants.LEVEL_CRITICAL;
            break;
    }
    return result;
}
 
Example #14
Source File: SyslogParameterTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testSSLTCPNetSyslogConfigCreate() {
	TCPNetSyslogConfig config = null;
	
	config = new SSLTCPNetSyslogConfig();
	assertTrue(config.getSyslogWriterClass() == SSLTCPNetSyslogWriter.class);

	config = new SSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH);
	assertTrue(config.getSyslogClass() == SSLTCPNetSyslog.class);
	assertEquals(SyslogConstants.FACILITY_AUTH,config.getFacility());

	config = new SSLTCPNetSyslogConfig("hostname0");
	assertEquals("hostname0",config.getHost());
	config.setHost("hostname1");
	assertEquals("hostname1",config.getHost());

	config = new SSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname2");
	assertEquals("hostname2",config.getHost());

	config = new SSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname3",2222);
	assertEquals("hostname3",config.getHost());
	assertEquals(2222,config.getPort());
	config.setPort(3333);
	assertEquals(3333,config.getPort());

	config = new SSLTCPNetSyslogConfig("hostname4",4444);
	assertEquals("hostname4",config.getHost());
	assertEquals(4444,config.getPort());
}
 
Example #15
Source File: MultipleSyslogCreateTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void log(int level, String message) {
	if (SyslogConstants.LEVEL_DEBUG == level) { debug(message); }
	if (SyslogConstants.LEVEL_INFO == level) { info(message); }
	if (SyslogConstants.LEVEL_NOTICE == level) { notice(message); }
	if (SyslogConstants.LEVEL_WARN == level) { warn(message); }
	if (SyslogConstants.LEVEL_ERROR == level) { error(message); }
	if (SyslogConstants.LEVEL_CRITICAL == level) { critical(message); }
	if (SyslogConstants.LEVEL_ALERT == level) { alert(message); }
	if (SyslogConstants.LEVEL_EMERGENCY == level) { emergency(message); }
}
 
Example #16
Source File: MultipleSyslogCreateTest.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void log(int level, SyslogMessageIF message) {
	if (SyslogConstants.LEVEL_DEBUG == level) { debug(message); }
	if (SyslogConstants.LEVEL_INFO == level) { info(message); }
	if (SyslogConstants.LEVEL_NOTICE == level) { notice(message); }
	if (SyslogConstants.LEVEL_WARN == level) { warn(message); }
	if (SyslogConstants.LEVEL_ERROR == level) { error(message); }
	if (SyslogConstants.LEVEL_CRITICAL == level) { critical(message); }
	if (SyslogConstants.LEVEL_ALERT == level) { alert(message); }
	if (SyslogConstants.LEVEL_EMERGENCY == level) { emergency(message); }
}
 
Example #17
Source File: SyslogIsNotAvailableDuringServerBootTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setupContainer() throws Exception {
    container.start();
    host = CoreUtils.stripSquareBrackets(TestSuiteEnvironment.getServerAddress());
    final JavaArchive deployment = createDeployment();
    deploy(deployment);
    SyslogServer.shutdown();
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.UDP);
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.TCP);
    setupServer();
    container.stop();
}
 
Example #18
Source File: Log4jSyslogBackLogHandler.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static Level getLog4jLevel(int level) {
	switch(level) {
		case SyslogConstants.LEVEL_DEBUG: 		return Level.DEBUG;
		case SyslogConstants.LEVEL_INFO: 		return Level.INFO;
		case SyslogConstants.LEVEL_NOTICE: 		return Level.INFO;
		case SyslogConstants.LEVEL_WARN: 		return Level.WARN;
		case SyslogConstants.LEVEL_ERROR: 		return Level.ERROR;
		case SyslogConstants.LEVEL_CRITICAL: 	return Level.ERROR;
		case SyslogConstants.LEVEL_ALERT: 		return Level.ERROR;
		case SyslogConstants.LEVEL_EMERGENCY: 	return Level.FATAL;
		
		default:
			return Level.WARN;
	}
}
 
Example #19
Source File: StructuredSyslogMessage.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static String nilProtect(final String value) {
	if (value == null || value.trim().length() == 0) {
		return SyslogConstants.STRUCTURED_DATA_NILVALUE;
	}

	return value;
}
 
Example #20
Source File: AbstractSyslogReconnectionTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static void startSyslogServers(String host) throws InterruptedException {
    udpServer = createAndStartSyslogInstance(
            new UDPSyslogServerConfig(),
            host,
            SYSLOG_UDP_PORT,
            SyslogConstants.UDP);
    tcpServer = createAndStartSyslogInstance(
            new TCPSyslogServerConfig(),
            host,
            SYSLOG_TCP_PORT,
            SyslogConstants.TCP);
    // reconnection timeout is 5sec for TCP syslog handler
    Thread.sleep(6 * ADJUSTED_SECOND);
}
 
Example #21
Source File: SyslogUtility.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static final String getLevelString(int level) {
	switch(level) {
		case SyslogConstants.LEVEL_DEBUG: return "DEBUG";
		case SyslogConstants.LEVEL_INFO: return "INFO";
		case SyslogConstants.LEVEL_NOTICE: return "NOTICE";
		case SyslogConstants.LEVEL_WARN: return "WARN";
		case SyslogConstants.LEVEL_ERROR: return "ERROR";
		case SyslogConstants.LEVEL_CRITICAL: return "CRITICAL";
		case SyslogConstants.LEVEL_ALERT: return "ALERT";
		case SyslogConstants.LEVEL_EMERGENCY: return "EMERGENCY";
		
		default:
			return "UNKNOWN";
	}
}
 
Example #22
Source File: StructuredSyslogServerEvent.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void parseProcessId() {
	int i = this.message.indexOf(' ');

	if (i > -1) {
		this.processId = this.message.substring(0, i).trim();
		this.message = this.message.substring(i + 1);
	}

	if (SyslogConstants.STRUCTURED_DATA_NILVALUE.equals(this.processId)) {
		this.processId = null;
	}
}
 
Example #23
Source File: StructuredSyslogServerEvent.java    From syslog4j with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void parseApplicationName() {
	int i = this.message.indexOf(' ');

	if (i > -1) {
		this.applicationName = this.message.substring(0, i).trim();
		this.message = this.message.substring(i + 1);
		parseProcessId();
	}

	if (SyslogConstants.STRUCTURED_DATA_NILVALUE.equals(this.applicationName)) {
		this.applicationName = null;
	}
}
 
Example #24
Source File: SyslogMessage.java    From hop with Apache License 2.0 4 votes vote down vote up
public boolean init() {

    if ( super.init() ) {
      String servername = environmentSubstitute( meta.getServerName() );

      // Check target server
      if ( Utils.isEmpty( servername ) ) {
        logError( BaseMessages.getString( PKG, "SyslogMessage.MissingServerName" ) );
      }

      // Check if message field is provided
      if ( Utils.isEmpty( meta.getMessageFieldName() ) ) {
        logError( BaseMessages.getString( PKG, "SyslogMessage.Error.MessageFieldMissing" ) );
        return false;
      }

      int nrPort = Const.toInt( environmentSubstitute( meta.getPort() ), SyslogDefs.DEFAULT_PORT );

      if ( meta.isAddTimestamp() ) {
        // add timestamp to message
        data.datePattern = environmentSubstitute( meta.getDatePattern() );
        if ( Utils.isEmpty( data.datePattern ) ) {
          logError( BaseMessages.getString( PKG, "SyslogMessage.DatePatternEmpty" ) );
          return false;
        }
      }

      try {
        // Connect to syslog ...
        data.syslog = getSyslog();
        data.syslog.initialize( SyslogConstants.UDP, new UDPNetSyslogConfig() );
        data.syslog.getConfig().setHost( servername );
        data.syslog.getConfig().setPort( nrPort );
        data.syslog.getConfig().setFacility( meta.getFacility() );
        data.syslog.getConfig().setSendLocalName( false );
        data.syslog.getConfig().setSendLocalTimestamp( false );
      } catch ( Exception ex ) {
        logError( BaseMessages.getString( PKG, "SyslogMessage.UnknownHost", servername, ex.getMessage() ) );
        logError( Const.getStackTracker( ex ) );
        return false;
      }
      return true;
    }
    return false;
  }
 
Example #25
Source File: TLSAuditLogToTCPSyslogTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected String getSyslogProtocol() {
    return SyslogConstants.TCP;
}
 
Example #26
Source File: SyslogMessageModifierTest.java    From syslog4j with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void testSequential() {
	// PREPARE
	
	List events = new ArrayList();
	String message = null;
	
	String protocol = getClientProtocol();
	SyslogIF syslog = getSyslog(protocol);
	syslog.getConfig().removeAllMessageModifiers();
	
	// SET UP

	SequentialSyslogMessageModifier sequentialModifier = SequentialSyslogMessageModifier.createDefault();
	syslog.getConfig().addMessageModifier(sequentialModifier);
	assertEquals(sequentialModifier.getConfig().getFirstNumber(),SequentialSyslogMessageModifierConfig.createDefault().getFirstNumber());
	
	// ZERO

	message = "[TEST] Sequence Test";
	syslog.info(message);
	events.add(message + " #0000");

	// ONE

	message = "[TEST] Sequence Test";
	syslog.info(message);
	events.add(message + " #0001");

	// NINE THOUSAND NINE HUNDRED NIGHTY EIGHT
	
	sequentialModifier.setNextSequence(SyslogConstants.LEVEL_INFO,9998);
	
	message = "[TEST] Sequence Test";
	syslog.info(message);
	events.add(message + " #9998");

	// NINE THOUSAND NINE HUNDRED NIGHTY NINE
	
	message = "[TEST] Sequence Test";
	syslog.info(message);
	events.add(message + " #9999");

	// ZERO
	
	message = "[TEST] Sequence Test";
	syslog.info(message);
	events.add(message + " #0000");

	// VERIFY
	
	SyslogUtility.sleep(pause);
	syslog.flush();
	verifySendReceive(events,false,false);
}
 
Example #27
Source File: MultipleSyslogConfig.java    From syslog4j with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean isUseStructuredData() {
	return SyslogConstants.USE_STRUCTURED_DATA_DEFAULT;
}
 
Example #28
Source File: AuditLogToUDPSyslogSetup.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected String getSyslogProtocol() {
    return SyslogConstants.UDP;
}
 
Example #29
Source File: MultipleSyslogConfig.java    From syslog4j with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int getMaxMessageLength() {
	return SyslogConstants.MAX_MESSAGE_LENGTH_DEFAULT;
}
 
Example #30
Source File: MultipleSyslogConfig.java    From syslog4j with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean isThrowExceptionOnWrite() {
	return SyslogConstants.THROW_EXCEPTION_ON_WRITE_DEFAULT;
}