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


Java Syslog类代码示例

本文整理汇总了Java中org.productivity.java.syslog4j.Syslog的典型用法代码示例。如果您正苦于以下问题:Java Syslog类的具体用法?Java Syslog怎么用?Java Syslog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Syslog类属于org.productivity.java.syslog4j包,在下文中一共展示了Syslog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHashVerify

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void testHashVerify() {
	SyslogIF syslog = Syslog.getInstance("tcp");
	
	HashSyslogMessageModifier modifier = HashSyslogMessageModifier.createMD5();
	modifier.getConfig().setSuffix(null);
	
	String message = "md5 hash Test 1212 ABAB";
	
	String modifiedMessage = modifier.modify(syslog,0,0,message);
	System.out.println(modifiedMessage);
	
	if (!modifier.verify(message,"fqfK2PYV76Wv9yNQjLoVeg==")) {
		fail();
	}

	if (!modifier.verify(message,Base64.decode("fqfK2PYV76Wv9yNQjLoVeg=="))) {
		fail();
	}

	if (!modifier.verify(modifiedMessage)) {
		fail();
	}
	
	assertFalse(modifier.verify(null));
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:26,代码来源:SyslogMessageModifierVerifyTest.java

示例2: testMacVerify

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void testMacVerify() {
	SyslogIF syslog = Syslog.getInstance("udp");
	
	MacSyslogMessageModifier modifier = MacSyslogMessageModifier.createHmacMD5("fb7Jl0VGnzY5ehJCdeff7bSZ5Vk=");
	modifier.getConfig().setPrefix(" ");
	modifier.getConfig().setSuffix(null);
	
	String message = "hmacmd5 Test 3434 DCDC";
	
	String modifiedMessage = modifier.modify(syslog,0,0,message);
	System.out.println(modifiedMessage);
	
	if (!modifier.verify(message,"MfWJ4XhFiMlPwnFEJ401zA==")) {
		fail();
	}

	if (!modifier.verify(message,Base64.decode("MfWJ4XhFiMlPwnFEJ401zA=="))) {
		fail();
	}

	if (!modifier.verify(modifiedMessage)) {
		fail();
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:25,代码来源:SyslogMessageModifierVerifyTest.java

示例3: setUp

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void setUp() {
	UDPNetSyslogConfig config = new UDPNetSyslogConfig();
	
	assertTrue(config.isCacheHostAddress());
	config.setCacheHostAddress(false);
	assertFalse(config.isCacheHostAddress());
	
	assertTrue(config.isThrowExceptionOnInitialize());
	config.setThrowExceptionOnInitialize(false);
	assertFalse(config.isThrowExceptionOnInitialize());
	
	assertFalse(config.isThrowExceptionOnWrite());
	config.setThrowExceptionOnWrite(true);
	assertTrue(config.isThrowExceptionOnWrite());
	
	Syslog.createInstance("log4jUdp",config);
	
	String protocol = getServerProtocol();
	
	startServerThread(protocol);
	SyslogUtility.sleep(100);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:23,代码来源:AbstractLog4jSyslog4jTest.java

示例4: testStructuredSyslogMessage

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void testStructuredSyslogMessage() {
	SyslogConfigIF config = new UDPNetSyslogConfig();
	config.setUseStructuredData(true);
	assertTrue(config.isUseStructuredData());
	config.setUseStructuredData(false);
	assertFalse(config.isUseStructuredData());
	
	SyslogIF syslog = Syslog.createInstance("testStructuredSyslog",config);
	
	SyslogMessageProcessorIF messageProcessor = new StructuredSyslogMessageProcessor();
	syslog.setStructuredMessageProcessor(messageProcessor);
	assertEquals(messageProcessor,syslog.getStructuredMessageProcessor());
	
	SyslogMessageIF m1 = new StructuredSyslogMessage("test1",new HashMap(),"test2");
	SyslogMessageIF m2 = new StructuredSyslogMessage("test1",new HashMap(),"test2");
	SyslogMessageIF m3 = new StructuredSyslogMessage("test3",new HashMap(),"test2");
	SyslogMessageIF m4 = new StructuredSyslogMessage("test1",new HashMap(),"test4");
	
	assertFalse(m1.equals(null));
	assertFalse(m1.equals("Wrong Class"));
	assertTrue(m1.equals(m1));
	assertTrue(m2.equals(m2));
	
	assertFalse(m1.equals(m3));
	assertFalse(m1.equals(m4));
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:27,代码来源:SyslogParameterTest.java

示例5: testCreateAndDestroyByProtocol

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void testCreateAndDestroyByProtocol() {
	UDPNetSyslogConfig config = new UDPNetSyslogConfig();
	config.setPort(999);
	
	SyslogIF syslog = Syslog.createInstance("udpToDestroy",config);

	assertEquals(SyslogMessageProcessor.getDefault(),syslog.getMessageProcessor());		
	SyslogMessageProcessorIF messageProcessor = new FakeMessageProcessor();
	syslog.setMessageProcessor(messageProcessor);
	assertEquals(messageProcessor,syslog.getMessageProcessor());	
	
	SyslogIF matchSyslog = Syslog.getInstance("udpToDestroy");
	
	assertEquals(syslog,matchSyslog);
	
	Syslog.destroyInstance("");
	Syslog.destroyInstance("udpToDestroy");
	
	try {
		Syslog.getInstance("udpToDestroy");
		fail("udpToDestroy should not exist");
		
	} catch (SyslogRuntimeException sre) {
		//
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:27,代码来源:SyslogCreateAndDestroyTest.java

示例6: getSyslog

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
protected SyslogIF getSyslog(String protocol) {
	if (!Syslog.exists(protocol)) {
		fail("Protocol \"" + protocol + "\" does not exist");
	}
	
	SyslogIF syslog = Syslog.getInstance(protocol);
	
	if (!(syslog instanceof MultipleSyslog)) {
		syslog.getConfig().setIdent(APP_ID);
	}
	
	if (!(syslog.getConfig() instanceof MultipleSyslogConfig)) {
		syslog.getConfig().setPort(TEST_PORT);
	}
	
	return syslog;
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:18,代码来源:AbstractNetSyslog4jTest.java

示例7: tearDown

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void tearDown() {
	System.out.print("Shutting down Syslog...");
	Syslog.shutdown();
	System.out.println("done.");

	SyslogUtility.sleep(100);
	
	System.out.print("Shutting down SyslogServer...");
	SyslogServer.shutdown();
	System.out.println("done.");
	
	SyslogUtility.sleep(100);

	Syslog.initialize();
	SyslogServer.initialize();
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:17,代码来源:AbstractNetSyslog4jTest.java

示例8: setupPoolConfig

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
protected void setupPoolConfig(boolean threaded, int maxActive, int maxWait) {
	PooledTCPNetSyslogConfig config = new PooledTCPNetSyslogConfig();
	
	config.setThreaded(threaded);
	config.setThrowExceptionOnWrite(true);
	config.setThrowExceptionOnInitialize(true);
	
	if (maxWait > 0) {
		config.setMaxWait(maxWait);
	}
	
	if (maxActive > 0) {
		config.setMaxActive(maxActive);
	}
		
	Syslog.createInstance("pooledTcp",config);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:18,代码来源:PooledTCPNetSyslog4jTest.java

示例9: setupPoolConfig

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
protected void setupPoolConfig(boolean threaded, int maxActive, int maxWait) {
	PooledSSLTCPNetSyslogConfig config = new PooledSSLTCPNetSyslogConfig();

	config.setThreaded(threaded);
	config.setThrowExceptionOnWrite(true);
	config.setThrowExceptionOnInitialize(true);
	
	if (maxWait > 0) {
		config.setMaxWait(maxWait);
	}
	
	if (maxActive > 0) {
		config.setMaxActive(maxActive);
	}
		
	Syslog.createInstance("pooledSslTcp",config);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:18,代码来源:PooledSSLTCPNetSyslog4jTest.java

示例10: testTruncate

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void testTruncate() {
	setMessageLength(10);
	
	SyslogIF syslog = Syslog.getInstance("split");
	syslog.getConfig().setTruncateMessage(true);
	
	syslog.info("T");
	syslog.info("Test 1234");
	syslog.info("Test 12345");
	syslog.info("Test 654321");
	syslog.info("Test 12345 For now is the time for all good men to come to the aid of their country");
	
	assertSyslog(syslog,new String[] {"T", "Test 1234", "Test 12345", "Test 65432", "Test 12345" } );
	
	syslog.flush();
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:17,代码来源:SplitSyslogTest.java

示例11: SyslogClient

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
/**
 * Init class for server at url:port and the given protocol. The "prefix" String will be added to every message
 */
public SyslogClient(String url, int port, LogInsightProtocol proto, String prefix) throws Exception {
	checkParam(url, "url");
	checkParam(proto, "protocol");

	if (proto.equals(LogInsightProtocol.SYSLOG_TCP)) {
		syslog = Syslog.getInstance("tcp");
	} else if (proto.equals(LogInsightProtocol.SYSLOG_UDP)) {
		syslog = Syslog.getInstance("udp");
	} else if (proto.equals(LogInsightProtocol.SYSLOG_TLS)) {
		SSLTCPNetSyslogConfig syslogConfig = new SSLTCPNetSyslogConfig(url, port);
		syslog = Syslog.createInstance("sslTcp", syslogConfig);
	} else {
		throw new Exception("Protocol " + proto.toString() + " is not supported. Use one of " +
				LogInsightProtocol.SYSLOG_TCP + ", " + LogInsightProtocol.SYSLOG_UDP + 
	                        " or " + LogInsightProtocol.SYSLOG_TLS);
	}

	syslog.getConfig().setUseStructuredData(true);
	syslog.getConfig().setHost(url);
	syslog.getConfig().setPort(port);

	this.prefix = prefix;
}
 
开发者ID:BillRothVMware,项目名称:bora-strata-mar27,代码行数:27,代码来源:SyslogClient.java

示例12: LogUploadClient

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public LogUploadClient(String url, int port, LogInsightProtocol proto) {
	this.url = url;
	this.port = port;
	this.proto = proto;

	assert (!proto.equals(LogInsightProtocol.UNKNOWN));

	if (proto.equals(LogInsightProtocol.SYSLOG_TCP)) {
		syslog = Syslog.getInstance("tcp");
	} else if (proto.equals(LogInsightProtocol.SYSLOG_UDP)) {
		syslog = Syslog.getInstance("udp");
	} else {
		System.err.println(proto + " not supported. Exiting...");
		System.exit(1);
	}
	syslog.getConfig().setHost(url);
	syslog.getConfig().setPort(port);
}
 
开发者ID:BillRothVMware,项目名称:bora-strata-mar27,代码行数:19,代码来源:LogUploadClient.java

示例13: createNorthboundInstance

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
/**
    * This is here, for now, until it can be properly wired and proper configuration can be created.
    * This allows generic 127.0.0.1:UDP/514 to work with OpenNMS having no configuration.  This is
    * trickery in its finest hour.
    */
   private void createNorthboundInstance() throws SyslogRuntimeException {
   	
   	LogUtils.infof(this, "Creating Syslog Northbound Instance:%s", m_destination.getName());
   	
   	String instName = m_destination.getName();
   	int facility = convertFacility(m_destination.getFacility());
   	SyslogProtocol protocol = m_destination.getProtocol();
   	SyslogConfigIF instanceConfiguration = createConfig(m_destination, protocol, facility);
   	instanceConfiguration.setIdent("OpenNMS");
   	instanceConfiguration.setCharSet(m_destination.getCharSet());
   	instanceConfiguration.setMaxMessageLength(m_destination.getMaxMessageLength());
   	instanceConfiguration.setSendLocalName(m_destination.isSendLocalName());
   	instanceConfiguration.setSendLocalTimestamp(m_destination.isSendLocalTime());
   	instanceConfiguration.setTruncateMessage(m_destination.isTruncateMessage());
   	instanceConfiguration.setUseStructuredData(SyslogConstants.USE_STRUCTURED_DATA_DEFAULT);

   	try {
   		Syslog.createInstance(instName, instanceConfiguration);
   	} catch (SyslogRuntimeException e) {
   		String msg = "Could not create northbound instance '%s': %s";
   		LogUtils.errorf(this, e, msg, instName, e);
   		throw e;
   	}

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:31,代码来源:SyslogNorthbounder.java

示例14: log

import org.productivity.java.syslog4j.Syslog; //导入依赖的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

示例15: flush

import org.productivity.java.syslog4j.Syslog; //导入依赖的package包/类
public void flush() throws SyslogRuntimeException {
	for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
		String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
		
		SyslogIF syslog = Syslog.getInstance(protocol);
		
		syslog.flush();
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:MultipleSyslog.java


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