Java Code Examples for org.productivity.java.syslog4j.SyslogIF#log()
The following examples show how to use
org.productivity.java.syslog4j.SyslogIF#log() .
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: MultipleSyslog.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
public void log(int level, String message) { for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) { String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i); SyslogIF syslog = Syslog.getInstance(protocol); syslog.log(level,message); } }
Example 2
Source File: MultipleSyslog.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
public void log(int level, SyslogMessageIF message) { for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) { String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i); SyslogIF syslog = Syslog.getInstance(protocol); syslog.log(level,message); } }
Example 3
Source File: MaxQueueSizeTest.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
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 4
Source File: AbstractNetSyslog4jTest.java From syslog4j with GNU Lesser General Public License v2.1 | 2 votes |
public void _testSendReceivePCIMessages(boolean sortEvents, boolean sortRecordedEvents){ List events = new ArrayList(); String protocol = getClientProtocol(); SyslogIF syslog = getSyslog(protocol); PCISyslogMessage message = new PCISyslogMessage(); message.setUserId("[TEST]"); syslog.debug(message); events.add(message.createMessage()); syslog.info(message); events.add(message.createMessage()); syslog.notice(message); events.add(message.createMessage()); syslog.warn(message); events.add(message.createMessage()); syslog.error(message); events.add(message.createMessage()); syslog.critical(message); events.add(message.createMessage()); syslog.alert(message); events.add(message.createMessage()); syslog.emergency(message); events.add(message.createMessage()); syslog.log(SyslogConstants.LEVEL_INFO,message); events.add(message.createMessage()); SyslogUtility.sleep(100); syslog.flush(); verifySendReceive(events,sortEvents,sortRecordedEvents); }
Example 5
Source File: AbstractNetSyslog4jTest.java From syslog4j with GNU Lesser General Public License v2.1 | 2 votes |
public void _testSendReceiveStructuredMessages(boolean sortEvents, boolean sortRecordedEvents){ List events = new ArrayList(); String protocol = getClientProtocol(); SyslogIF syslog = getSyslog(protocol); this.server.getConfig().setUseStructuredData(true); Map m2 = new HashMap(); m2.put("foo","bar"); Map m1 = new HashMap(); m1.put("testa",m2); StructuredSyslogMessageIF message = new StructuredSyslogMessage("[TEST]",m1,"testb"); syslog.debug(message); events.add(message.createMessage()); syslog.info(message); events.add(message.createMessage()); syslog.notice(message); events.add(message.createMessage()); syslog.warn(message); events.add(message.createMessage()); syslog.error(message); events.add(message.createMessage()); syslog.critical(message); events.add(message.createMessage()); syslog.alert(message); events.add(message.createMessage()); syslog.emergency(message); events.add(message.createMessage()); syslog.log(SyslogConstants.LEVEL_INFO,message); events.add(message.createMessage()); syslog.log(SyslogConstants.LEVEL_INFO,message.createMessage()); events.add(message.createMessage()); SyslogUtility.sleep(100); syslog.flush(); verifySendReceive(events,sortEvents,sortRecordedEvents); this.server.getConfig().setUseStructuredData(false); }