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


Java Syslog.getInstance方法代码示例

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


在下文中一共展示了Syslog.getInstance方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: execute

import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public Result execute(Result previousResult, int nr)
{		
	Result result = previousResult;
	result.setNrErrors(1);
	result.setResult( false );
	
	String servername=environmentSubstitute(getServerName());
	
	if(Const.isEmpty(servername)) {
		logError(BaseMessages.getString(PKG, "JobEntrySyslog.MissingServerName"));
	}
	
	String messageString=environmentSubstitute(getMessage());
	
	if(Const.isEmpty(messageString)) {
		logError(BaseMessages.getString(PKG, "JobEntrySyslog.MissingMessage"));
	}
	
	int nrPort=Const.toInt(environmentSubstitute(getPort()), SyslogDefs.DEFAULT_PORT);

	SyslogIF syslog=null;
	try {
		String pattern=null;
		
		if(isAddTimestamp()) {
			// add timestamp to message
			pattern= environmentSubstitute(getDatePattern());
			if(Const.isEmpty(pattern)) {
				logError(BaseMessages.getString(PKG, "JobEntrySyslog.DatePatternEmpty"));
				throw new KettleException(BaseMessages.getString(PKG, "JobEntrySyslog.DatePatternEmpty"));
			}
		
		}
		
		// Open syslog connection
		// Set a Specific Host, then Log to It
		syslog = Syslog.getInstance("udp");
		syslog.getConfig().setHost(servername);
		syslog.getConfig().setPort(nrPort);
		syslog.getConfig().setFacility(getFacility());
		syslog.getConfig().setSendLocalName(false);
		syslog.getConfig().setSendLocalTimestamp(false);
		SyslogDefs.sendMessage(syslog, SyslogDefs.getPriority(getPriority()), 
				messageString, isAddTimestamp(), pattern, isAddHostName());
		
		// message was sent
		result.setNrErrors(0);
		result.setResult(true);
	} catch(Exception e){
		logError(BaseMessages.getString(PKG, "JobEntrySyslog.ErrorSendingMessage", e.toString())); //$NON-NLS-1$
	} finally{
       	if(syslog!=null) syslog.shutdown();
       }

	return result;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:57,代码来源:JobEntrySyslog.java

示例9: 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

示例10: 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

示例11: shutdown

import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public void shutdown() 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.shutdown();
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:MultipleSyslog.java

示例12: testSyslog4jBackLogHandler

import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
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) {
		//
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:38,代码来源:SyslogParameterTest.java

示例13: testNonDefinedSyslogInstance

import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public void testNonDefinedSyslogInstance() {
	try {
		Syslog.getInstance("not_defined");
		fail("not_defined shouldn't exist");
		
	} catch (SyslogRuntimeException sre) {
		assertTrue(sre.getMessage().startsWith("Syslog protocol \"not_defined\" not defined; call Syslogger.createSyslogInstance(protocol,config) first or use one of the following instances: "));
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:NonDefinedSyslogInstanceTest.java

示例14: SyslogMessageGenerator

import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public SyslogMessageGenerator() {
	syslog = Syslog.getInstance("udp");
	syslog.getConfig().setUseStructuredData(false);
	syslog.getConfig().setHost("localhost");
	syslog.getConfig().setFacility(SyslogIF.FACILITY_LOCAL0);
	count = DEFAULT_COUNT;
	delay = DEFAULT_DELAY;
}
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:9,代码来源:SyslogMessageGenerator.java

示例15: Syslog4jBackLogHandler

import org.productivity.java.syslog4j.Syslog; //导入方法依赖的package包/类
public Syslog4jBackLogHandler(String protocol) {
	this.syslog = Syslog.getInstance(protocol);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:4,代码来源:Syslog4jBackLogHandler.java


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