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


Java SyslogServer类代码示例

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


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

示例1: setUp

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  serverStream = new ByteArrayOutputStream();
  PrintStream ps = new PrintStream(serverStream);

  final TCPNetSyslogServerConfig tcpNetSyslogServerConfig = new TCPNetSyslogServerConfig(45553);
  tcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));

  final UDPNetSyslogServerConfig udpNetSyslogServerConfig = new UDPNetSyslogServerConfig(45553);
  udpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));

  final SSLTCPNetSyslogServerConfig ssltcpNetSyslogServerConfig = new SSLTCPNetSyslogServerConfig();
  ssltcpNetSyslogServerConfig.setPort(45554);
  ssltcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
  final String keyStore = this.getClass().getClassLoader().getResource("test-keystore.jks").getFile();
  ssltcpNetSyslogServerConfig.setKeyStore(keyStore);
  ssltcpNetSyslogServerConfig.setKeyStorePassword("password");
  ssltcpNetSyslogServerConfig.setTrustStore(keyStore);
  ssltcpNetSyslogServerConfig.setTrustStorePassword("password");

  SyslogServer.createThreadedInstance("testTcp", tcpNetSyslogServerConfig);
  SyslogServer.createThreadedInstance("testUdp", udpNetSyslogServerConfig);
  SyslogServer.createThreadedInstance("testTls", ssltcpNetSyslogServerConfig);
}
 
开发者ID:serioussam,项目名称:syslogappender,代码行数:25,代码来源:SyslogAppenderTest.java

示例2: startServerThread

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected void startServerThread(String protocol) {
	assertTrue(SyslogServer.exists(protocol));
	
	this.server = SyslogServer.getInstance(protocol);
	
	if (isSyslogServerTcpBacklog() && this.server.getConfig() instanceof TCPNetSyslogServerConfig) {
		((TCPNetSyslogServerConfig) this.server.getConfig()).setBacklog(0);
	}
	
	AbstractNetSyslogServerConfig config = (AbstractNetSyslogServerConfig) this.server.getConfig();
	config.setPort(TEST_PORT);
	config.addEventHandler(this.recorderEventHandler);

	if (this.server.getThread() == null) {
		Thread t = new Thread(this.server);
		t.setName("SyslogServer: " + protocol);
		t.start();
		
		this.server.setThread(t);
		
		assertEquals(t,this.server.getThread());
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:24,代码来源:AbstractNetSyslog4jTest.java

示例3: tearDown

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

示例4: setUp

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected void setUp() {
    serverStream = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(serverStream);

    final TCPNetSyslogServerConfig tcpNetSyslogServerConfig = new TCPNetSyslogServerConfig(45553);
    tcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));

    final UDPNetSyslogServerConfig udpNetSyslogServerConfig = new UDPNetSyslogServerConfig(45553);
    udpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));

    final SSLTCPNetSyslogServerConfig ssltcpNetSyslogServerConfig = new SSLTCPNetSyslogServerConfig();
    ssltcpNetSyslogServerConfig.setPort(45554);
    ssltcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
    ssltcpNetSyslogServerConfig.setKeyStore(this.getClass().getClassLoader().getResource("test-keystore.jks").getFile());
    ssltcpNetSyslogServerConfig.setKeyStorePassword("password");
    ssltcpNetSyslogServerConfig.setTrustStore(this.getClass().getClassLoader().getResource("test-keystore.jks").getFile());
    ssltcpNetSyslogServerConfig.setTrustStorePassword("password");

    SyslogServer.createThreadedInstance("testTcp", tcpNetSyslogServerConfig);
    SyslogServer.createThreadedInstance("testUdp", udpNetSyslogServerConfig);
    SyslogServer.createThreadedInstance("testTls", ssltcpNetSyslogServerConfig);
}
 
开发者ID:papertrail,项目名称:logback-syslog4j,代码行数:23,代码来源:Syslog4jAppenderTest.java

示例5: tearDown

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
/**
 * Stops syslog server and removes auditlog configuration.
 *
 */
@Override
public void tearDown(ManagementClient managementClient) throws Exception {
    // stop syslog server
    SyslogServer.shutdown();
    server.setThread(null);
    server.getConfig().removeAllEventHandlers();

    removeResource(managementClient, AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR);
    removeResource(managementClient, AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR2);
    removeResource(managementClient, AUDIT_SYSLOG_HANDLER_ADDR2);
    removeResource(managementClient, AUDIT_SYSLOG_HANDLER_ADDR);

    CoreUtils.applyUpdate(Util.getWriteAttributeOperation(AUDIT_LOG_LOGGER_ADDR, LOG_READ_ONLY, false),
            managementClient.getControllerClient());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:AuditLogToSyslogSetup.java

示例6: tearDown

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Override
public void tearDown(final ManagementClient managementClient) throws Exception {
    // stop syslog server
    LOGGER.info("stopping syslog server");
    SyslogServer.shutdown();
    LOGGER.info("syslog server stopped");

    // remove syslog-profile
    final ModelNode op = Operations.createRemoveOperation(SYSLOG_PROFILE_ADDR);
    op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false);
    op.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    executeOperation(op);
    LOGGER.info("syslog server logging profile removed");

    super.tearDown(managementClient);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:SyslogHandlerTestCase.java

示例7: startServer

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
/**
 * Getting ready for tests.
 * @throws InterruptedException 
 */
@Before
public void startServer() throws InterruptedException {
    MockLogAppender.setupLogging();
    

    SyslogServerConfigIF serverConfig = new UDPNetSyslogServerConfig(SERVER_HOST, SERVER_PORT);
    serverConfig.setShutdownWait(0);
    m_logStream = new TestPrintStream(new StringOutputStream());
    SyslogServerEventHandlerIF eventHandler = new PrintStreamSyslogServerEventHandler(m_logStream);
    serverConfig.addEventHandler(eventHandler);
    m_server = SyslogServer.createThreadedInstance("test-udp", serverConfig);
    
    
    m_server.initialize("udp", serverConfig);
    
    //Need this sleep, found a deadlock in the server.
    Thread.sleep(100);
    m_server.run();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:SyslogNorthBounderTest.java

示例8: startServerThread

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected void startServerThread(String protocol) {
	this.server = SyslogServer.getInstance(protocol);
	
	AbstractNetSyslogServerConfig config = (AbstractNetSyslogServerConfig) this.server.getConfig();
	config.setPort(TEST_PORT);
	config.addEventHandler(this.recorderEventHandler);

	this.server = SyslogServer.getThreadedInstance(protocol);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:AbstractLog4jSyslog4jTest.java

示例9: testCreateAndDestroyServerByProtocol

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void testCreateAndDestroyServerByProtocol() {
	UDPNetSyslogServerConfig config = new UDPNetSyslogServerConfig();
	config.setPort(999);
	
	SyslogServerIF server = SyslogServer.createInstance("udpToDestroy",config);
	
	SyslogServerIF matchServer = SyslogServer.getInstance("udpToDestroy");
	
	assertEquals(server,matchServer);
	
	SyslogServer.destroyInstance("");
	SyslogServer.destroyInstance("udpToDestroy");
	
	try {
		SyslogServer.getInstance("udpToDestroy");
		fail("udpToDestroy should not exist");
		
	} catch (SyslogRuntimeException sre) {
		//
	}
	
	assertFalse(SyslogServer.getSuppressRuntimeExceptions());
	SyslogServer.setSuppressRuntimeExceptions(true);
	assertTrue(SyslogServer.getSuppressRuntimeExceptions());

	assertNull(SyslogServer.getInstance("udpToDestroy"));

	SyslogServer.setSuppressRuntimeExceptions(false);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:30,代码来源:SyslogCreateAndDestroyTest.java

示例10: testNonDefinedSyslogServerInstance

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void testNonDefinedSyslogServerInstance() {
	try {
		SyslogServer.getInstance("not_defined");
		fail("not_defined shouldn't exist");
		
	} catch (SyslogRuntimeException sre) {
		assertTrue(sre.getMessage().startsWith("SyslogServer instance \"not_defined\" not defined; use \"tcp\" or \"udp\" or call SyslogServer.createInstance(protocol,config) first"));
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:NonDefinedSyslogInstanceTest.java

示例11: _testMaxActiveSockets

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected int _testMaxActiveSockets(TCPNetSyslogServerConfigIF serverConfig) {
	Counter c = new Counter();
	
	serverConfig.setMaxActiveSockets(2);
	serverConfig.addEventHandler(c);
	
	SyslogServer.createThreadedInstance("tcp_maxactivesockets",serverConfig);
	
	TCPNetSyslogConfigIF config = new TCPNetSyslogConfig();
	config.setPort(8888);
		
	SyslogIF syslog1 = Syslog.createInstance("tcp_maxactivesockets1",config);
	syslog1.info("test1");
	syslog1.flush();
	SyslogUtility.sleep(200);
	
	SyslogIF syslog2 = Syslog.createInstance("tcp_maxactivesockets2",config);
	syslog2.info("test2");
	syslog2.flush();
	SyslogUtility.sleep(200);
	
	SyslogIF syslog3 = Syslog.createInstance("tcp_maxactivesockets3",config);
	syslog3.info("test3");
	syslog3.flush();
	SyslogUtility.sleep(200);

	syslog1.shutdown();
	SyslogUtility.sleep(200);

	Syslog.destroyInstance("tcp_maxactivesockets1");
	Syslog.destroyInstance("tcp_maxactivesockets2");
	Syslog.destroyInstance("tcp_maxactivesockets3");
	
	SyslogServer.destroyInstance("tcp_maxactivesockets");
	
	return c.counter;
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:38,代码来源:MaxActiveSocketsTest.java

示例12: setUp

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void setUp() throws Exception {
	if (ONCE) {
		ONCE = false;
		
	} else {
		SyslogServer.getInstance(getServerProtocol()).getConfig().setHost("127.0.0.1");
	}

	super.setUp();	
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:11,代码来源:TCPNetSyslog4jTest.java

示例13: testFreshConnectionInterval

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void testFreshConnectionInterval() {
	TCPNetSyslogServerConfigIF serverConfig = new TCPNetSyslogServerConfig();
	serverConfig.setPort(8888);
	
	SocketCounter counter = new SocketCounter();
	serverConfig.addEventHandler(counter);
	
	SyslogServerIF server = SyslogServer.createThreadedInstance("tcp_8888",serverConfig);

	SyslogUtility.sleep(100);

	TCPNetSyslogConfigIF config = new TCPNetSyslogConfig();
	config.setPort(8888);
	config.setFreshConnectionInterval(300);
	
	SyslogIF syslog = Syslog.createInstance("tcp_8888",config);

	for(int i=0; i<10; i++) {
		syslog.info("message " + i);
		SyslogUtility.sleep(100);
	}
	
	SyslogUtility.sleep(100);
	
	SyslogServer.destroyInstance(server);
	Syslog.destroyInstance(syslog);

	SyslogUtility.sleep(100);

	assertEquals("OpenCounter",3,counter.openCounter);
	assertEquals("EventCounter",10,counter.eventCounter);
	assertEquals("CloseCounter",3,counter.closeCounter);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:34,代码来源:FreshConnectionIntervalTest.java

示例14: getServerProtocol

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected String getServerProtocol() throws Exception {
	SSLTCPNetSyslogServerConfigIF config = new SSLTCPNetSyslogServerConfig();
	SSLConfigUtil.configure(config);
	SyslogServer.createThreadedInstance("pooledSslTcp", config);
	
	return "pooledSslTcp";
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:8,代码来源:PooledSSLTCPNetSyslog4jTest.java

示例15: setup

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
/**
 * Starts Syslog server and configures syslog handler in the AS.
 *
 */
@Override
public void setup(ManagementClient managementClient) throws Exception {
    // clear created server instances (TCP/UDP)
    SyslogServer.shutdown();

    // start and set syslog server

    final String host = managementClient.getMgmtAddress();
    SyslogServerConfigIF config = getSyslogConfig();
    config.setUseStructuredData(true);
    config.setHost(host);
    config.setPort(SYSLOG_PORT);
    config.addEventHandler(new BlockedSyslogServerEventHandler());
    final String syslogProtocol = getSyslogProtocol();
    server = SyslogServer.createInstance(syslogProtocol, config);
    // start syslog server
    SyslogServer.getThreadedInstance(syslogProtocol);

    // Add the normal syslog handler
    addSyslogHandler(managementClient, AUDIT_SYSLOG_HANDLER_ADDR, host, null, null);

    // Add the syslog handler we will switch to
    addSyslogHandler(managementClient, AUDIT_SYSLOG_HANDLER_ADDR2, host, "TestApp", Facility.LINE_PRINTER);

    // Reference the first audit logger for now
    ModelNode op = Util.createAddOperation(AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR);
    CoreUtils.applyUpdate(op, managementClient.getControllerClient());

    op = Util.getWriteAttributeOperation(AUDIT_LOG_LOGGER_ADDR, LOG_READ_ONLY, false);
    CoreUtils.applyUpdate(op, managementClient.getControllerClient());

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:37,代码来源:AuditLogToSyslogSetup.java


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