当前位置: 首页>>代码示例>>Java>>正文


Java SyslogIF.log方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:MultipleSyslog.java

示例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));
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:38,代码来源:MaxQueueSizeTest.java

示例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.");
	}
}
 
开发者ID:kbase,项目名称:cmonkey,代码行数:9,代码来源:JsonServerSyslog.java

示例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);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:44,代码来源:AbstractNetSyslog4jTest.java

示例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);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:56,代码来源:AbstractNetSyslog4jTest.java


注:本文中的org.productivity.java.syslog4j.SyslogIF.log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。