Java Code Examples for org.productivity.java.syslog4j.server.SyslogServer#getThreadedInstance()
The following examples show how to use
org.productivity.java.syslog4j.server.SyslogServer#getThreadedInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLog4jSyslog4jTest.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
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); }
Example 2
Source File: AuditLogToSyslogSetup.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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()); }
Example 3
Source File: AbstractSyslogReconnectionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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; }
Example 4
Source File: BackLogTCPNetSyslog4jTest.java From syslog4j with GNU Lesser General Public License v2.1 | 4 votes |
public void run() { SyslogUtility.sleep(this.pause); SyslogServer.getThreadedInstance(this.protocol); }
Example 5
Source File: SyslogHandlerTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@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); // Add a JSON formatter builder.addStep(Operations.createAddOperation(JSON_FORMATTER_ADDR)); executeOperation(builder.build()); LOGGER.info("syslog server setup complete"); }
Example 6
Source File: CommandLineNetSyslog4jTest.java From syslog4j with GNU Lesser General Public License v2.1 | 3 votes |
public void testSendReceive(String protocol, boolean useSyslogClass) { SyslogServer.getInstance(protocol).getConfig().setPort(1514); SyslogServerIF syslogServer = SyslogServer.getThreadedInstance(protocol); SyslogUtility.sleep(100); CaptureHandler captureHandler = new CaptureHandler(); syslogServer.getConfig().addEventHandler(captureHandler); String message = "test message"; try { if (useSyslogClass) { Syslog.main(new String[] { "-p", "1514", protocol, message }); } else { SyslogMain.main(new String[] { "-p", "1514", protocol, message }, false); } } catch (Exception e) { // } SyslogUtility.sleep(250); assertTrue(captureHandler.capturedEvent.getMessage().endsWith(message)); syslogServer.shutdown(); SyslogUtility.sleep(100); }