本文整理汇总了Java中org.productivity.java.syslog4j.SyslogIF.log方法的典型用法代码示例。如果您正苦于以下问题:Java SyslogIF.log方法的具体用法?Java SyslogIF.log怎么用?Java SyslogIF.log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.productivity.java.syslog4j.SyslogIF
的用法示例。
在下文中一共展示了SyslogIF.log方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
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);
}
}
示例2: testMaxQueueSize
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
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));
}
示例3: logToSystem
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void logToSystem(SyslogIF log, int level, String message) {
try {
log.log(level, message);
//log.flush();
} catch (Throwable ex) {
System.out.println("JsonServerSyslog: Error writing to syslog (" + ex.getMessage() + "), see user defined log-file instead of syslog.");
}
}
示例4: _testSendReceivePCIMessages
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
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);
}
示例5: _testSendReceiveStructuredMessages
import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
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);
}