• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SyslogServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public static void main(String[] args) throws SyslogRuntimeException, UnknownHostException {

		// Details for the properties -
		// http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/JSSERefGuide.html
		System.setProperty("jsse.enableSNIExtension", "false");
		// just in case...
		System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
		System.setProperty("sun.security.ssl.allowLegacyHelloMessages", "true");

		// clear created server instances (TCP/UDP)
		SyslogServer.shutdown();

		String syslogProtocol = "tls";
		System.out.println("Simple syslog server (RFC-5424)");
		System.out.println("Usage:");
		System.out.println("  java -jar syslog-server.jar [protocol]");
		System.out.println();
		System.out.println("Possible protocols: udp, tcp, tls");
		System.out.println();

		if (args.length > 0) {
			syslogProtocol = args[0];
		} else {
			System.err.println("No protocol provided. Defaulting to " + syslogProtocol);
		}

		SyslogServerConfigIF config = getSyslogConfig(syslogProtocol);
		if (config == null) {
			System.err.println("Unsupported Syslog protocol: " + syslogProtocol);
			System.exit(1);
		}
		config.setUseStructuredData(true);
//		config.setHost(InetAddress.getByName(null).getHostAddress());
		config.setHost("0.0.0.0");
		config.setPort(SYSLOG_PORT);

		System.out.println("Starting Simple Syslog Server");
		System.out.println("Protocol:     " + syslogProtocol);
		System.out.println("Bind address: " + config.getHost());
		System.out.println("Port:         " + config.getPort());

		// start syslog server
		SyslogServer.createThreadedInstance(syslogProtocol, config);
	}
 
开发者ID:kwart,项目名称:simple-syslog-server,代码行数:45,代码来源:Server.java


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


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


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


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


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


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


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


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


示例17: setup

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Override
public void setup(final ManagementClient managementClient) throws Exception {
    LOGGER.info("starting syslog server on port " + PORT);

    // clear created server instances (TCP/UDP)
    SyslogServer.shutdown();
    // create a new UDP instance
    final String host = CoreUtils.stripSquareBrackets(managementClient.getMgmtAddress());
    final UDPSyslogServerConfig config = new UDPSyslogServerConfig();
    config.setPort(PORT);
    config.setHost(host);
    config.setUseStructuredData(true);
    config.addEventHandler(new BlockedSyslogServerEventHandler());
    SyslogServer.createInstance(UDP, config);
    // start syslog server
    SyslogServer.getThreadedInstance(SyslogConstants.UDP);

    final CompositeOperationBuilder builder = CompositeOperationBuilder.create();

    // create syslog-profile
    builder.addStep(Operations.createAddOperation(SYSLOG_PROFILE_ADDR));

    ModelNode op = Operations.createAddOperation(SYSLOG_HANDLER_ADDR);
    op.get("level").set("TRACE");
    op.get("port").set(PORT);
    op.get("server-address").set(host);
    op.get("enabled").set("true");
    builder.addStep(op);

    op = Operations.createAddOperation(SYSLOG_PROFILE_ROOT_LOGGER_ADDR);
    op.get("level").set("TRACE");
    op.get("handlers").add("SYSLOG");
    builder.addStep(op);

    executeOperation(builder.build());

    LOGGER.info("syslog server setup complete");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:39,代码来源:SyslogHandlerTestCase.java


示例18: setupContainer

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Before
public void setupContainer() throws Exception {
    container.start();
    host = CoreUtils.stripSquareBrackets(TestSuiteEnvironment.getServerAddress());
    final JavaArchive deployment = createDeployment();
    deploy(deployment);
    SyslogServer.shutdown();
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.UDP);
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.TCP);
    setupServer();
    container.stop();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:SyslogIsNotAvailableDuringServerBootTestCase.java


示例19: setupContainer

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Before
public void setupContainer() throws Exception {
    container.start();
    host = CoreUtils.stripSquareBrackets(TestSuiteEnvironment.getServerAddress());
    final JavaArchive deployment = createDeployment();
    deploy(deployment);
    SyslogServer.shutdown();
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.UDP);
    BlockedAllProtocolsSyslogServerEventHandler.initializeForProtocol(SyslogConstants.TCP);
    startSyslogServers(host);
    setupServer();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:ReconnectSyslogServerTestCase.java


示例20: createAndStartSyslogInstance

import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
private static SyslogServerIF createAndStartSyslogInstance(SyslogServerConfigIF config, String host, int port, String protocol) {
    config.setUseStructuredData(true);
    config.setHost(host);
    config.setPort(port);
    config.addEventHandler(new BlockedAllProtocolsSyslogServerEventHandler(protocol));
    SyslogServerIF syslogServer = SyslogServer.createInstance(protocol, config);
    SyslogServer.getThreadedInstance(protocol);
    return syslogServer;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:AbstractSyslogReconnectionTestCase.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Field类代码示例发布时间:2022-05-22
下一篇:
Java SimpleTextExtractionStrategy类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap