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


Java SyslogConstants类代码示例

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


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

示例1: run

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
@Override
public void run() {
	this.shutdown = false;
	try {
		this.ds = createDatagramSocket();
	} catch (Exception e) {
		System.err.println("Creating DatagramSocket failed");
		e.printStackTrace();
		throw new SyslogRuntimeException(e);
	}

	byte[] receiveData = new byte[SyslogConstants.SYSLOG_BUFFER_SIZE];

	while (!this.shutdown) {
		try {
			final DatagramPacket dp = new DatagramPacket(receiveData, receiveData.length);
			this.ds.receive(dp);
			final SyslogServerEventIF event = new Rfc5424SyslogEvent(receiveData, dp.getOffset(), dp.getLength());
			System.out.println(">>> Syslog message came: " + event);
		} catch (SocketException se) {
			se.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}
}
 
开发者ID:kwart,项目名称:simple-syslog-server,代码行数:27,代码来源:UDPSyslogServer.java

示例2: destroyInstance

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public synchronized static final void destroyInstance(String protocol) {
	if (protocol == null || "".equals(protocol.trim())) {
		return;
	}

	String _protocol = protocol.toLowerCase();
	
	if (instances.containsKey(_protocol)) {
		SyslogUtility.sleep(SyslogConstants.THREAD_LOOP_INTERVAL_DEFAULT);
		
		SyslogServerIF syslogServer = (SyslogServerIF) instances.get(_protocol);

		try {
			syslogServer.shutdown();
			
		} finally {
			instances.remove(_protocol);
		}
		
	} else {
		throwRuntimeException("Cannot destroy server protocol \"" + protocol + "\" instance; call shutdown instead");
		return;
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:25,代码来源:SyslogServer.java

示例3: initialize

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void initialize() throws SyslogRuntimeException {
	this.tcpNetSyslogServerConfig = null;
	
	try {
		this.tcpNetSyslogServerConfig = (TCPNetSyslogServerConfigIF) this.syslogServerConfig;
		
	} catch (ClassCastException cce) {
		throw new SyslogRuntimeException("config must be of type TCPNetSyslogServerConfig");
	}
	
	if (this.syslogServerConfig == null) {
		throw new SyslogRuntimeException("config cannot be null");
	}

	if (this.tcpNetSyslogServerConfig.getBacklog() < 1) {
		this.tcpNetSyslogServerConfig.setBacklog(SyslogConstants.SERVER_SOCKET_BACKLOG_DEFAULT);
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:19,代码来源:TCPNetSyslogServer.java

示例4: testSequentialSyslogMessageModifierConfigCreate

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void testSequentialSyslogMessageModifierConfigCreate() {
	SequentialSyslogMessageModifierConfig config = new SequentialSyslogMessageModifierConfig();
	
	assertEquals(SyslogConstants.CHAR_SET_DEFAULT,config.getCharSet());
	config.setCharSet("Unicode");
	assertEquals("Unicode",config.getCharSet());
	
	config.setFirstNumber(500);
	assertEquals(config.getFirstNumber(),500);

	config.setLastNumber(1000);
	assertEquals(config.getLastNumber(),1000);

	config.setLastNumber(499);
	assertEquals(config.getLastNumber(),1000);
	
	config.setFirstNumber(1001);
	assertEquals(config.getFirstNumber(),500);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:20,代码来源:SyslogParameterTest.java

示例5: createNorthboundInstance

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

示例6: parseApplicationName

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
protected void parseApplicationName() {
	int i = this.message.indexOf(' ');

	if (i > -1) {
		this.applicationName = this.message.substring(0, i).trim();
		this.message = this.message.substring(i + 1);
		parseProcessId();
	}

	if (SyslogConstants.STRUCTURED_DATA_NILVALUE.equals(this.applicationName)) {
		this.applicationName = null;
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:14,代码来源:StructuredSyslogServerEvent.java

示例7: parseProcessId

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
protected void parseProcessId() {
	int i = this.message.indexOf(' ');

	if (i > -1) {
		this.processId = this.message.substring(0, i).trim();
		this.message = this.message.substring(i + 1);
	}

	if (SyslogConstants.STRUCTURED_DATA_NILVALUE.equals(this.processId)) {
		this.processId = null;
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:13,代码来源:StructuredSyslogServerEvent.java

示例8: getLevelString

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public static final String getLevelString(int level) {
	switch(level) {
		case SyslogConstants.LEVEL_DEBUG: return "DEBUG";
		case SyslogConstants.LEVEL_INFO: return "INFO";
		case SyslogConstants.LEVEL_NOTICE: return "NOTICE";
		case SyslogConstants.LEVEL_WARN: return "WARN";
		case SyslogConstants.LEVEL_ERROR: return "ERROR";
		case SyslogConstants.LEVEL_CRITICAL: return "CRITICAL";
		case SyslogConstants.LEVEL_ALERT: return "ALERT";
		case SyslogConstants.LEVEL_EMERGENCY: return "EMERGENCY";
		
		default:
			return "UNKNOWN";
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:16,代码来源:SyslogUtility.java

示例9: nilProtect

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public static String nilProtect(final String value) {
	if (value == null || value.trim().length() == 0) {
		return SyslogConstants.STRUCTURED_DATA_NILVALUE;
	}

	return value;
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:8,代码来源:StructuredSyslogMessage.java

示例10: getLog4jLevel

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
protected static Level getLog4jLevel(int level) {
	switch(level) {
		case SyslogConstants.LEVEL_DEBUG: 		return Level.DEBUG;
		case SyslogConstants.LEVEL_INFO: 		return Level.INFO;
		case SyslogConstants.LEVEL_NOTICE: 		return Level.INFO;
		case SyslogConstants.LEVEL_WARN: 		return Level.WARN;
		case SyslogConstants.LEVEL_ERROR: 		return Level.ERROR;
		case SyslogConstants.LEVEL_CRITICAL: 	return Level.ERROR;
		case SyslogConstants.LEVEL_ALERT: 		return Level.ERROR;
		case SyslogConstants.LEVEL_EMERGENCY: 	return Level.FATAL;
		
		default:
			return Level.WARN;
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:16,代码来源:Log4jSyslogBackLogHandler.java

示例11: run

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void run() {
	while(!this.shutdown || !this.queuedMessages.isEmpty()) {
		List queuedMessagesCopy = null;
		
		synchronized(this.queuedMessages) {
			queuedMessagesCopy = new LinkedList(this.queuedMessages);
			this.queuedMessages.clear();
		}
		
		if (queuedMessagesCopy != null) {
			while(!queuedMessagesCopy.isEmpty()) {
				byte[] message = (byte[]) queuedMessagesCopy.remove(0);
						
				try {
					write(message);
					
					this.syslog.setBackLogStatus(false);
						
				} catch (SyslogRuntimeException sre) {
					this.syslog.backLog(SyslogConstants.LEVEL_INFO,SyslogUtility.newString(this.syslog.getConfig(),message),sre);
				}
			}
		}
		
		SyslogUtility.sleep(this.syslogConfig.getThreadLoopInterval());
	}
	
	runCompleted();
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:30,代码来源:AbstractSyslogWriter.java

示例12: shutdown

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public synchronized void shutdown() throws SyslogRuntimeException {
	this.shutdown = true;
	
	if (this.syslogConfig.isThreaded()) {
		long timeStart = System.currentTimeMillis();
		boolean done = false;
		
		while(!done) {
			if (this.socket == null || this.socket.isClosed()) {
				done = true;
				
			} else {
				long now = System.currentTimeMillis();
				
				if (now > (timeStart + this.tcpNetSyslogConfig.getMaxShutdownWait())) {
					closeSocket(this.socket);
					this.thread.interrupt();
					done = true;
				}
				
				if (!done) {
					SyslogUtility.sleep(SyslogConstants.SHUTDOWN_INTERVAL);
				}
			}
		}
		
	} else {
		if (this.socket == null || this.socket.isClosed()) {
			return;
		}
		
		closeSocket(this.socket);
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:35,代码来源:TCPNetSyslogWriter.java

示例13: log

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void log(int level, String message) {
	if (SyslogConstants.LEVEL_DEBUG == level) { debug(message); }
	if (SyslogConstants.LEVEL_INFO == level) { info(message); }
	if (SyslogConstants.LEVEL_NOTICE == level) { notice(message); }
	if (SyslogConstants.LEVEL_WARN == level) { warn(message); }
	if (SyslogConstants.LEVEL_ERROR == level) { error(message); }
	if (SyslogConstants.LEVEL_CRITICAL == level) { critical(message); }
	if (SyslogConstants.LEVEL_ALERT == level) { alert(message); }
	if (SyslogConstants.LEVEL_EMERGENCY == level) { emergency(message); }
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:11,代码来源:MultipleSyslogCreateTest.java

示例14: testPooledTCPNetSyslogConfigCreate

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void testPooledTCPNetSyslogConfigCreate() {
	PooledTCPNetSyslogConfig config = null;
	
	config = new PooledTCPNetSyslogConfig();
	assertTrue(config.getSyslogWriterClass() == TCPNetSyslogWriter.class);

	config = new PooledTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH);
	assertTrue(config.getSyslogClass() == PooledTCPNetSyslog.class);
	assertEquals(SyslogConstants.FACILITY_AUTH,config.getFacility());

	config = new PooledTCPNetSyslogConfig("hostname0");
	assertEquals("hostname0",config.getHost());
	config.setHost("hostname1");
	assertEquals("hostname1",config.getHost());

	config = new PooledTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname2");
	assertEquals("hostname2",config.getHost());

	config = new PooledTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname3",2222);
	assertEquals("hostname3",config.getHost());
	assertEquals(2222,config.getPort());
	config.setPort(3333);
	assertEquals(3333,config.getPort());

	config = new PooledTCPNetSyslogConfig("hostname4",4444);
	assertEquals("hostname4",config.getHost());
	assertEquals(4444,config.getPort());
	
	testPoolConfig(config);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:31,代码来源:SyslogParameterTest.java

示例15: testPooledSSLTCPNetSyslogConfigCreate

import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void testPooledSSLTCPNetSyslogConfigCreate() {
	PooledTCPNetSyslogConfig config = null;
	
	config = new PooledSSLTCPNetSyslogConfig();
	assertTrue(config.getSyslogWriterClass() == SSLTCPNetSyslogWriter.class);

	config = new PooledSSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH);
	assertTrue(config.getSyslogClass() == SSLTCPNetSyslog.class);
	assertEquals(SyslogConstants.FACILITY_AUTH,config.getFacility());

	config = new PooledSSLTCPNetSyslogConfig("hostname0");
	assertEquals("hostname0",config.getHost());
	config.setHost("hostname1");
	assertEquals("hostname1",config.getHost());

	config = new PooledSSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname2");
	assertEquals("hostname2",config.getHost());

	config = new PooledSSLTCPNetSyslogConfig(SyslogConstants.FACILITY_AUTH,"hostname3",2222);
	assertEquals("hostname3",config.getHost());
	assertEquals(2222,config.getPort());
	config.setPort(3333);
	assertEquals(3333,config.getPort());

	config = new PooledSSLTCPNetSyslogConfig("hostname4",4444);
	assertEquals("hostname4",config.getHost());
	assertEquals(4444,config.getPort());
	
	testPoolConfig(config);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:31,代码来源:SyslogParameterTest.java


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