本文整理汇总了Java中org.productivity.java.syslog4j.SyslogConstants类的典型用法代码示例。如果您正苦于以下问题:Java SyslogConstants类的具体用法?Java SyslogConstants怎么用?Java SyslogConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyslogConstants类属于org.productivity.java.syslog4j包,在下文中一共展示了SyslogConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testSyslog4jBackLogHandler
import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的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
示例17: testMaxQueueSize
import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
public void testMaxQueueSize() {
int catchCount = 5;
int maxQueueSize = 5;
int messagesToSend = 15;
int port = 7777;
FakeSyslogServer server = new FakeSyslogServer(port,catchCount);
Thread thread = new Thread(server);
thread.start();
BackLogCounter counter = new BackLogCounter();
TCPNetSyslogConfigIF syslogConfig = new TCPNetSyslogConfig();
syslogConfig.setPort(port);
assertEquals(syslogConfig.getMaxQueueSize(),SyslogConstants.MAX_QUEUE_SIZE_DEFAULT);
syslogConfig.setMaxQueueSize(maxQueueSize);
syslogConfig.addBackLogHandler(counter);
syslogConfig.addBackLogHandler(NullSyslogBackLogHandler.INSTANCE);
SyslogIF syslog = Syslog.createInstance("maxQueueSizeTest",syslogConfig);
for(int i=1; i<=messagesToSend; i++) {
syslog.log(SyslogConstants.LEVEL_INFO,"test line " + i);
}
SyslogUtility.sleep(500);
server.shutdown = true;
SyslogUtility.sleep(500);
System.out.println("Sent Messages: " + messagesToSend);
System.out.println("Received Messages: " + server.count);
System.out.println("Backlogged Messages: " + counter.count);
assertEquals(messagesToSend,(server.count+counter.count));
}
开发者ID:syslog4j,项目名称:syslog4j,代码行数:38,代码来源:MaxQueueSizeTest.java
示例18: run
import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
@Override
public void run() {
this.shutdown = false;
try {
this.ds = createDatagramSocket();
} catch (Exception e) {
LOGGER.error("Creating DatagramSocket failed", e);
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());
List list = this.syslogServerConfig.getEventHandlers();
for (int i = 0; i < list.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) list.get(i);
eventHandler.event(this, event);
}
} catch (SocketException se) {
LOGGER.warn("SocketException occurred", se);
} catch (IOException ioe) {
LOGGER.warn("IOException occurred", ioe);
}
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:30,代码来源:UDPSyslogServer.java
示例19: getSyslogLevel
import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的package包/类
/**
* Convert JBoss Logger.Level to Syslog log level.
*
* @param jbossLogLevel
*
* @return
*/
private int getSyslogLevel(Level jbossLogLevel) {
final int result;
switch (jbossLogLevel) {
case TRACE:
case DEBUG:
result = SyslogConstants.LEVEL_DEBUG;
break;
case INFO:
result = SyslogConstants.LEVEL_INFO;
break;
case WARN:
result = SyslogConstants.LEVEL_WARN;
break;
case ERROR:
result = SyslogConstants.LEVEL_ERROR;
break;
case FATAL:
result = SyslogConstants.LEVEL_EMERGENCY;
break;
default:
// unexpected
result = SyslogConstants.LEVEL_CRITICAL;
break;
}
return result;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:34,代码来源:SyslogHandlerTestCase.java
示例20: setup
import org.productivity.java.syslog4j.SyslogConstants; //导入依赖的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
注:本文中的org.productivity.java.syslog4j.SyslogConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论