Merge branch 'reformat'
This commit is contained in:
commit
7380b94581
@ -14,20 +14,20 @@ import org.graylog2.syslog4j.util.SyslogUtility;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a Singleton interface for Syslog4j client implementations.
|
* This class provides a Singleton interface for Syslog4j client implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Usage examples:</p>
|
* <p>Usage examples:</p>
|
||||||
*
|
* <p/>
|
||||||
* <b>Direct</b>
|
* <b>Direct</b>
|
||||||
* <pre>
|
* <pre>
|
||||||
* Syslog.getInstance("udp").info("log message");
|
* Syslog.getInstance("udp").info("log message");
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
* <p/>
|
||||||
* <b>Via Instance</b>
|
* <b>Via Instance</b>
|
||||||
* <pre>
|
* <pre>
|
||||||
* SyslogIF syslog = Syslog.getInstance("udp");
|
* SyslogIF syslog = Syslog.getInstance("udp");
|
||||||
* syslog.info();
|
* syslog.info();
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
@ -126,14 +126,14 @@ public final class Syslog implements SyslogConstants {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Use createInstance(protocol,config) to create your own Syslog instance.
|
* Use createInstance(protocol,config) to create your own Syslog instance.
|
||||||
*
|
* <p/>
|
||||||
* <p>First, create an implementation of SyslogConfigIF, such as UdpNetSyslogConfig.</p>
|
* <p>First, create an implementation of SyslogConfigIF, such as UdpNetSyslogConfig.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Second, configure that configuration instance.</p>
|
* <p>Second, configure that configuration instance.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Third, call createInstance(protocol,config) using a short & simple
|
* <p>Third, call createInstance(protocol,config) using a short & simple
|
||||||
* String for the protocol argument.</p>
|
* String for the protocol argument.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Fourth, either use the returned instance of SyslogIF, or in later code
|
* <p>Fourth, either use the returned instance of SyslogIF, or in later code
|
||||||
* call getInstance(protocol) with the protocol chosen in the previous step.</p>
|
* call getInstance(protocol) with the protocol chosen in the previous step.</p>
|
||||||
*
|
*
|
||||||
@ -157,7 +157,7 @@ public final class Syslog implements SyslogConstants {
|
|||||||
|
|
||||||
SyslogIF syslog = null;
|
SyslogIF syslog = null;
|
||||||
|
|
||||||
synchronized(instances) {
|
synchronized (instances) {
|
||||||
if (instances.containsKey(syslogProtocol)) {
|
if (instances.containsKey(syslogProtocol)) {
|
||||||
throwRuntimeException("Syslog protocol \"" + protocol + "\" already defined");
|
throwRuntimeException("Syslog protocol \"" + protocol + "\" already defined");
|
||||||
return null;
|
return null;
|
||||||
@ -193,9 +193,9 @@ public final class Syslog implements SyslogConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog.initialize(syslogProtocol,config);
|
syslog.initialize(syslogProtocol, config);
|
||||||
|
|
||||||
instances.put(syslogProtocol,syslog);
|
instances.put(syslogProtocol, syslog);
|
||||||
}
|
}
|
||||||
|
|
||||||
return syslog;
|
return syslog;
|
||||||
@ -206,12 +206,12 @@ public final class Syslog implements SyslogConstants {
|
|||||||
* well as UNIX_SYSLOG and UNIX_SOCKET (if running on a Unix-based system).
|
* well as UNIX_SYSLOG and UNIX_SOCKET (if running on a Unix-based system).
|
||||||
*/
|
*/
|
||||||
public synchronized static final void initialize() {
|
public synchronized static final void initialize() {
|
||||||
createInstance(UDP,new UDPNetSyslogConfig());
|
createInstance(UDP, new UDPNetSyslogConfig());
|
||||||
createInstance(TCP,new TCPNetSyslogConfig());
|
createInstance(TCP, new TCPNetSyslogConfig());
|
||||||
|
|
||||||
if (OSDetectUtility.isUnix() && SyslogUtility.isClassExists(JNA_NATIVE_CLASS)) {
|
if (OSDetectUtility.isUnix() && SyslogUtility.isClassExists(JNA_NATIVE_CLASS)) {
|
||||||
createInstance(UNIX_SYSLOG,new UnixSyslogConfig());
|
createInstance(UNIX_SYSLOG, new UnixSyslogConfig());
|
||||||
createInstance(UNIX_SOCKET,new UnixSocketSyslogConfig());
|
createInstance(UNIX_SOCKET, new UnixSocketSyslogConfig());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ public final class Syslog implements SyslogConstants {
|
|||||||
|
|
||||||
SyslogUtility.sleep(SyslogConstants.THREAD_LOOP_INTERVAL_DEFAULT);
|
SyslogUtility.sleep(SyslogConstants.THREAD_LOOP_INTERVAL_DEFAULT);
|
||||||
|
|
||||||
while(i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
String protocol = (String) i.next();
|
String protocol = (String) i.next();
|
||||||
|
|
||||||
SyslogIF syslog = (SyslogIF) instances.get(protocol);
|
SyslogIF syslog = (SyslogIF) instances.get(protocol);
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syslog4jVersion provides a unique version identifier that is created during
|
* Syslog4jVersion provides a unique version identifier that is created during
|
||||||
* the build process.
|
* the build process.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: Syslog4jVersion.java,v 1.2 2008/10/28 01:07:06 cvs Exp $
|
* @version $Id: Syslog4jVersion.java,v 1.2 2008/10/28 01:07:06 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public final class Syslog4jVersion {
|
public final class Syslog4jVersion {
|
||||||
public static final String VERSION = "Syslog4j-graylog2 0.9.48 kroepke";
|
public static final String VERSION = "Syslog4j-graylog2 0.9.48 kroepke";
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogBackLogHandlerIF provides a last-chance mechanism to log messages that fail
|
* SyslogBackLogHandlerIF provides a last-chance mechanism to log messages that fail
|
||||||
* (for whatever reason) within the rest of Syslog.
|
* (for whatever reason) within the rest of Syslog.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Implementing the down(SyslogIF) method is an excellent way to add some sort of notification to
|
* <p>Implementing the down(SyslogIF) method is an excellent way to add some sort of notification to
|
||||||
* your application when a Syslog service is unavailable.</p>
|
* your application when a Syslog service is unavailable.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Implementing the up(SyslogIF) method can be used to notify your application when a Syslog
|
* <p>Implementing the up(SyslogIF) method can be used to notify your application when a Syslog
|
||||||
* service has returned.</p>
|
* service has returned.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogBackLogHandlerIF.java,v 1.2 2009/01/28 15:13:52 cvs Exp $
|
* @version $Id: SyslogBackLogHandlerIF.java,v 1.2 2009/01/28 15:13:52 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogBackLogHandlerIF {
|
public interface SyslogBackLogHandlerIF {
|
||||||
/**
|
/**
|
||||||
* Implement initialize() to handle one-time set-up for this backLog handler.
|
* Implement initialize() to handle one-time set-up for this backLog handler.
|
||||||
|
@ -3,17 +3,18 @@ package org.graylog2.syslog4j;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogCharSetIF provides control of the encoding character set within
|
* SyslogCharSetIF provides control of the encoding character set within
|
||||||
* several class of Syslog4j.
|
* several class of Syslog4j.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogCharSetIF.java,v 1.3 2008/11/07 15:15:41 cvs Exp $
|
* @version $Id: SyslogCharSetIF.java,v 1.3 2008/11/07 15:15:41 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogCharSetIF extends Serializable {
|
public interface SyslogCharSetIF extends Serializable {
|
||||||
public String getCharSet();
|
public String getCharSet();
|
||||||
|
|
||||||
public void setCharSet(String charSet);
|
public void setCharSet(String charSet);
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,90 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogConfigIF provides a common, extensible configuration interface for all
|
* SyslogConfigIF provides a common, extensible configuration interface for all
|
||||||
* implementations of SyslogIF.
|
* implementations of SyslogIF.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogConfigIF.java,v 1.19 2010/11/28 04:15:18 cvs Exp $
|
* @version $Id: SyslogConfigIF.java,v 1.19 2010/11/28 04:15:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogConfigIF extends SyslogConstants, SyslogCharSetIF {
|
public interface SyslogConfigIF extends SyslogConstants, SyslogCharSetIF {
|
||||||
public Class getSyslogClass();
|
public Class getSyslogClass();
|
||||||
|
|
||||||
public int getFacility();
|
public int getFacility();
|
||||||
|
|
||||||
public void setFacility(int facility);
|
public void setFacility(int facility);
|
||||||
|
|
||||||
public void setFacility(String facilityName);
|
public void setFacility(String facilityName);
|
||||||
|
|
||||||
public int getPort();
|
public int getPort();
|
||||||
|
|
||||||
public void setPort(int port) throws SyslogRuntimeException;
|
public void setPort(int port) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public String getLocalName();
|
public String getLocalName();
|
||||||
|
|
||||||
public void setLocalName(String localName) throws SyslogRuntimeException;
|
public void setLocalName(String localName) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public String getHost();
|
public String getHost();
|
||||||
|
|
||||||
public void setHost(String host) throws SyslogRuntimeException;
|
public void setHost(String host) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public String getIdent();
|
public String getIdent();
|
||||||
|
|
||||||
public void setIdent(String ident);
|
public void setIdent(String ident);
|
||||||
|
|
||||||
public String getCharSet();
|
public String getCharSet();
|
||||||
|
|
||||||
public void setCharSet(String charSet);
|
public void setCharSet(String charSet);
|
||||||
|
|
||||||
public boolean isIncludeIdentInMessageModifier();
|
public boolean isIncludeIdentInMessageModifier();
|
||||||
|
|
||||||
public void setIncludeIdentInMessageModifier(boolean throwExceptionOnInitialize);
|
public void setIncludeIdentInMessageModifier(boolean throwExceptionOnInitialize);
|
||||||
|
|
||||||
public boolean isThrowExceptionOnInitialize();
|
public boolean isThrowExceptionOnInitialize();
|
||||||
|
|
||||||
public void setThrowExceptionOnInitialize(boolean throwExceptionOnInitialize);
|
public void setThrowExceptionOnInitialize(boolean throwExceptionOnInitialize);
|
||||||
|
|
||||||
public boolean isThrowExceptionOnWrite();
|
public boolean isThrowExceptionOnWrite();
|
||||||
|
|
||||||
public void setThrowExceptionOnWrite(boolean throwExceptionOnWrite);
|
public void setThrowExceptionOnWrite(boolean throwExceptionOnWrite);
|
||||||
|
|
||||||
public boolean isSendLocalTimestamp();
|
public boolean isSendLocalTimestamp();
|
||||||
|
|
||||||
public void setSendLocalTimestamp(boolean sendLocalTimestamp);
|
public void setSendLocalTimestamp(boolean sendLocalTimestamp);
|
||||||
|
|
||||||
public boolean isSendLocalName();
|
public boolean isSendLocalName();
|
||||||
|
|
||||||
public void setSendLocalName(boolean sendLocalName);
|
public void setSendLocalName(boolean sendLocalName);
|
||||||
|
|
||||||
public boolean isTruncateMessage();
|
public boolean isTruncateMessage();
|
||||||
|
|
||||||
public void setTruncateMessage(boolean truncateMessage);
|
public void setTruncateMessage(boolean truncateMessage);
|
||||||
|
|
||||||
public boolean isUseStructuredData();
|
public boolean isUseStructuredData();
|
||||||
|
|
||||||
public void setUseStructuredData(boolean useStructuredData);
|
public void setUseStructuredData(boolean useStructuredData);
|
||||||
|
|
||||||
public int getMaxMessageLength();
|
public int getMaxMessageLength();
|
||||||
|
|
||||||
public void setMaxMessageLength(int maxMessageLength);
|
public void setMaxMessageLength(int maxMessageLength);
|
||||||
|
|
||||||
public void addMessageModifier(SyslogMessageModifierIF messageModifier);
|
public void addMessageModifier(SyslogMessageModifierIF messageModifier);
|
||||||
|
|
||||||
public void insertMessageModifier(int index, SyslogMessageModifierIF messageModifier);
|
public void insertMessageModifier(int index, SyslogMessageModifierIF messageModifier);
|
||||||
|
|
||||||
public void removeMessageModifier(SyslogMessageModifierIF messageModifier);
|
public void removeMessageModifier(SyslogMessageModifierIF messageModifier);
|
||||||
|
|
||||||
public void removeAllMessageModifiers();
|
public void removeAllMessageModifiers();
|
||||||
|
|
||||||
public void addBackLogHandler(SyslogBackLogHandlerIF backLogHandler);
|
public void addBackLogHandler(SyslogBackLogHandlerIF backLogHandler);
|
||||||
|
|
||||||
public void insertBackLogHandler(int index, SyslogBackLogHandlerIF backLogHandler);
|
public void insertBackLogHandler(int index, SyslogBackLogHandlerIF backLogHandler);
|
||||||
|
|
||||||
public void removeBackLogHandler(SyslogBackLogHandlerIF backLogHandler);
|
public void removeBackLogHandler(SyslogBackLogHandlerIF backLogHandler);
|
||||||
|
|
||||||
public void removeAllBackLogHandlers();
|
public void removeAllBackLogHandlers();
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogConstants provides several global constant values for several
|
* SyslogConstants provides several global constant values for several
|
||||||
* classes within Syslog4j.
|
* classes within Syslog4j.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogConstants.java,v 1.33 2011/01/11 05:11:13 cvs Exp $
|
* @version $Id: SyslogConstants.java,v 1.33 2011/01/11 05:11:13 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogConstants extends Serializable {
|
public interface SyslogConstants extends Serializable {
|
||||||
public static final String SYSLOG_PATH_DEFAULT = "/dev/log";
|
public static final String SYSLOG_PATH_DEFAULT = "/dev/log";
|
||||||
public static final String SYSLOG_HOST_DEFAULT = "localhost";
|
public static final String SYSLOG_HOST_DEFAULT = "localhost";
|
||||||
@ -75,27 +75,27 @@ public interface SyslogConstants extends Serializable {
|
|||||||
public static final byte TCP_MAX_ACTIVE_SOCKETS_BEHAVIOR_DEFAULT = 0;
|
public static final byte TCP_MAX_ACTIVE_SOCKETS_BEHAVIOR_DEFAULT = 0;
|
||||||
|
|
||||||
public static final int FACILITY_KERN = 0;
|
public static final int FACILITY_KERN = 0;
|
||||||
public static final int FACILITY_USER = 1<<3;
|
public static final int FACILITY_USER = 1 << 3;
|
||||||
public static final int FACILITY_MAIL = 2<<3;
|
public static final int FACILITY_MAIL = 2 << 3;
|
||||||
public static final int FACILITY_DAEMON = 3<<3;
|
public static final int FACILITY_DAEMON = 3 << 3;
|
||||||
public static final int FACILITY_AUTH = 4<<3;
|
public static final int FACILITY_AUTH = 4 << 3;
|
||||||
public static final int FACILITY_SYSLOG = 5<<3;
|
public static final int FACILITY_SYSLOG = 5 << 3;
|
||||||
|
|
||||||
public static final int FACILITY_LPR = 6<<3;
|
public static final int FACILITY_LPR = 6 << 3;
|
||||||
public static final int FACILITY_NEWS = 7<<3;
|
public static final int FACILITY_NEWS = 7 << 3;
|
||||||
public static final int FACILITY_UUCP = 8<<3;
|
public static final int FACILITY_UUCP = 8 << 3;
|
||||||
public static final int FACILITY_CRON = 9<<3;
|
public static final int FACILITY_CRON = 9 << 3;
|
||||||
public static final int FACILITY_AUTHPRIV = 10<<3;
|
public static final int FACILITY_AUTHPRIV = 10 << 3;
|
||||||
public static final int FACILITY_FTP = 11<<3;
|
public static final int FACILITY_FTP = 11 << 3;
|
||||||
|
|
||||||
public static final int FACILITY_LOCAL0 = 16<<3;
|
public static final int FACILITY_LOCAL0 = 16 << 3;
|
||||||
public static final int FACILITY_LOCAL1 = 17<<3;
|
public static final int FACILITY_LOCAL1 = 17 << 3;
|
||||||
public static final int FACILITY_LOCAL2 = 18<<3;
|
public static final int FACILITY_LOCAL2 = 18 << 3;
|
||||||
public static final int FACILITY_LOCAL3 = 19<<3;
|
public static final int FACILITY_LOCAL3 = 19 << 3;
|
||||||
public static final int FACILITY_LOCAL4 = 20<<3;
|
public static final int FACILITY_LOCAL4 = 20 << 3;
|
||||||
public static final int FACILITY_LOCAL5 = 21<<3;
|
public static final int FACILITY_LOCAL5 = 21 << 3;
|
||||||
public static final int FACILITY_LOCAL6 = 22<<3;
|
public static final int FACILITY_LOCAL6 = 22 << 3;
|
||||||
public static final int FACILITY_LOCAL7 = 23<<3;
|
public static final int FACILITY_LOCAL7 = 23 << 3;
|
||||||
|
|
||||||
public static final int SYSLOG_FACILITY_DEFAULT = FACILITY_USER;
|
public static final int SYSLOG_FACILITY_DEFAULT = FACILITY_USER;
|
||||||
|
|
||||||
|
@ -1,52 +1,71 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogIF provides a common interface for all Syslog4j client implementations.
|
* SyslogIF provides a common interface for all Syslog4j client implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogIF.java,v 1.9 2010/02/11 04:59:22 cvs Exp $
|
* @version $Id: SyslogIF.java,v 1.9 2010/02/11 04:59:22 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogIF extends SyslogConstants {
|
public interface SyslogIF extends SyslogConstants {
|
||||||
public void initialize(String protocol, SyslogConfigIF config) throws SyslogRuntimeException;
|
public void initialize(String protocol, SyslogConfigIF config) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public String getProtocol();
|
public String getProtocol();
|
||||||
|
|
||||||
public SyslogConfigIF getConfig();
|
public SyslogConfigIF getConfig();
|
||||||
|
|
||||||
public void backLog(int level, String message, Throwable reasonThrowable);
|
public void backLog(int level, String message, Throwable reasonThrowable);
|
||||||
|
|
||||||
public void backLog(int level, String message, String reason);
|
public void backLog(int level, String message, String reason);
|
||||||
|
|
||||||
public void log(int level, String message);
|
public void log(int level, String message);
|
||||||
|
|
||||||
public void debug(String message);
|
public void debug(String message);
|
||||||
|
|
||||||
public void info(String message);
|
public void info(String message);
|
||||||
|
|
||||||
public void notice(String message);
|
public void notice(String message);
|
||||||
|
|
||||||
public void warn(String message);
|
public void warn(String message);
|
||||||
|
|
||||||
public void error(String message);
|
public void error(String message);
|
||||||
|
|
||||||
public void critical(String message);
|
public void critical(String message);
|
||||||
|
|
||||||
public void alert(String message);
|
public void alert(String message);
|
||||||
|
|
||||||
public void emergency(String message);
|
public void emergency(String message);
|
||||||
|
|
||||||
public void log(int level, SyslogMessageIF message);
|
public void log(int level, SyslogMessageIF message);
|
||||||
|
|
||||||
public void debug(SyslogMessageIF message);
|
public void debug(SyslogMessageIF message);
|
||||||
|
|
||||||
public void info(SyslogMessageIF message);
|
public void info(SyslogMessageIF message);
|
||||||
|
|
||||||
public void notice(SyslogMessageIF message);
|
public void notice(SyslogMessageIF message);
|
||||||
|
|
||||||
public void warn(SyslogMessageIF message);
|
public void warn(SyslogMessageIF message);
|
||||||
|
|
||||||
public void error(SyslogMessageIF message);
|
public void error(SyslogMessageIF message);
|
||||||
|
|
||||||
public void critical(SyslogMessageIF message);
|
public void critical(SyslogMessageIF message);
|
||||||
|
|
||||||
public void alert(SyslogMessageIF message);
|
public void alert(SyslogMessageIF message);
|
||||||
|
|
||||||
public void emergency(SyslogMessageIF message);
|
public void emergency(SyslogMessageIF message);
|
||||||
|
|
||||||
public void flush() throws SyslogRuntimeException;
|
public void flush() throws SyslogRuntimeException;
|
||||||
|
|
||||||
public void shutdown() throws SyslogRuntimeException;
|
public void shutdown() throws SyslogRuntimeException;
|
||||||
|
|
||||||
public void setMessageProcessor(SyslogMessageProcessorIF messageProcessor);
|
public void setMessageProcessor(SyslogMessageProcessorIF messageProcessor);
|
||||||
|
|
||||||
public SyslogMessageProcessorIF getMessageProcessor();
|
public SyslogMessageProcessorIF getMessageProcessor();
|
||||||
|
|
||||||
public void setStructuredMessageProcessor(SyslogMessageProcessorIF messageProcessor);
|
public void setStructuredMessageProcessor(SyslogMessageProcessorIF messageProcessor);
|
||||||
|
|
||||||
public SyslogMessageProcessorIF getStructuredMessageProcessor();
|
public SyslogMessageProcessorIF getStructuredMessageProcessor();
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import java.io.InputStreamReader;
|
|||||||
/**
|
/**
|
||||||
* This class provides a command-line interface for Syslog4j
|
* This class provides a command-line interface for Syslog4j
|
||||||
* server implementations.
|
* server implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
@ -76,17 +76,55 @@ public class SyslogMain {
|
|||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(i < args.length) {
|
while (i < args.length) {
|
||||||
String arg = args[i++];
|
String arg = args[i++];
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
|
|
||||||
if ("-h".equals(arg)) { if (i == args.length) { options.usage = "Must specify host with -h"; return options; } match = true; options.host = args[i++]; }
|
if ("-h".equals(arg)) {
|
||||||
if ("-p".equals(arg)) { if (i == args.length) { options.usage = "Must specify port with -p"; return options; } match = true; options.port = args[i++]; }
|
if (i == args.length) {
|
||||||
if ("-l".equals(arg)) { if (i == args.length) { options.usage = "Must specify level with -l"; return options; } match = true; options.level = args[i++]; }
|
options.usage = "Must specify host with -h";
|
||||||
if ("-f".equals(arg)) { if (i == args.length) { options.usage = "Must specify facility with -f"; return options; } match = true; options.facility = args[i++]; }
|
return options;
|
||||||
if ("-i".equals(arg)) { if (i == args.length) { options.usage = "Must specify file with -i"; return options; } match = true; options.fileName = args[i++]; }
|
}
|
||||||
|
match = true;
|
||||||
|
options.host = args[i++];
|
||||||
|
}
|
||||||
|
if ("-p".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify port with -p";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.port = args[i++];
|
||||||
|
}
|
||||||
|
if ("-l".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify level with -l";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.level = args[i++];
|
||||||
|
}
|
||||||
|
if ("-f".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify facility with -f";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.facility = args[i++];
|
||||||
|
}
|
||||||
|
if ("-i".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify file with -i";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.fileName = args[i++];
|
||||||
|
}
|
||||||
|
|
||||||
if ("-q".equals(arg)) { match = true; options.quiet = true; }
|
if ("-q".equals(arg)) {
|
||||||
|
match = true;
|
||||||
|
options.quiet = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.protocol == null && !match) {
|
if (options.protocol == null && !match) {
|
||||||
match = true;
|
match = true;
|
||||||
@ -117,7 +155,7 @@ public class SyslogMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
main(args,true);
|
main(args, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args, boolean shutdown) throws Exception {
|
public static void main(String[] args, boolean shutdown) throws Exception {
|
||||||
@ -125,7 +163,11 @@ public class SyslogMain {
|
|||||||
|
|
||||||
if (options.usage != null) {
|
if (options.usage != null) {
|
||||||
usage(options.usage);
|
usage(options.usage);
|
||||||
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
|
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
|
||||||
|
System.exit(1);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.quiet) {
|
if (!options.quiet) {
|
||||||
@ -134,7 +176,11 @@ public class SyslogMain {
|
|||||||
|
|
||||||
if (!Syslog.exists(options.protocol)) {
|
if (!Syslog.exists(options.protocol)) {
|
||||||
usage("Protocol \"" + options.protocol + "\" not supported");
|
usage("Protocol \"" + options.protocol + "\" not supported");
|
||||||
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
|
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
|
||||||
|
System.exit(1);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SyslogIF syslog = Syslog.getInstance(options.protocol);
|
SyslogIF syslog = Syslog.getInstance(options.protocol);
|
||||||
@ -164,7 +210,7 @@ public class SyslogMain {
|
|||||||
System.out.println("Sending " + options.facility + "." + options.level + " message \"" + options.message + "\"");
|
System.out.println("Sending " + options.facility + "." + options.level + " message \"" + options.message + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog.log(level,options.message);
|
syslog.log(level, options.message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
@ -180,12 +226,12 @@ public class SyslogMain {
|
|||||||
|
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
|
|
||||||
while(line != null && line.length() > 0) {
|
while (line != null && line.length() > 0) {
|
||||||
if (!options.quiet) {
|
if (!options.quiet) {
|
||||||
System.out.println("Sending " + options.facility + "." + options.level + " message \"" + line + "\"");
|
System.out.println("Sending " + options.facility + "." + options.level + " message \"" + line + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog.log(level,line);
|
syslog.log(level, line);
|
||||||
|
|
||||||
line = br.readLine();
|
line = br.readLine();
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,15 @@ package org.graylog2.syslog4j;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogMessageIF provides a common interface for all Syslog4j event implementations.
|
* SyslogMessageIF provides a common interface for all Syslog4j event implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
|
* @version $Id: SyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogMessageIF extends Serializable {
|
public interface SyslogMessageIF extends Serializable {
|
||||||
public String createMessage();
|
public String createMessage();
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogMessageModifierConfigIF provides a common configuration interface for all
|
* SyslogMessageModifierConfigIF provides a common configuration interface for all
|
||||||
* Syslog4j message modifier implementations.
|
* Syslog4j message modifier implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogMessageModifierConfigIF.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: SyslogMessageModifierConfigIF.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogMessageModifierConfigIF extends SyslogConstants, SyslogCharSetIF {
|
public interface SyslogMessageModifierConfigIF extends SyslogConstants, SyslogCharSetIF {
|
||||||
public String getPrefix();
|
public String getPrefix();
|
||||||
|
|
||||||
public void setPrefix(String prefix);
|
public void setPrefix(String prefix);
|
||||||
|
|
||||||
public String getSuffix();
|
public String getSuffix();
|
||||||
|
|
||||||
public void setSuffix(String suffix);
|
public void setSuffix(String suffix);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogMessageModifierIF provides a common interface for all
|
* SyslogMessageModifierIF provides a common interface for all
|
||||||
* Syslog4j message modifier implementations.
|
* Syslog4j message modifier implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogMessageModifierIF.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: SyslogMessageModifierIF.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogMessageModifierIF extends SyslogConstants {
|
public interface SyslogMessageModifierIF extends SyslogConstants {
|
||||||
public String modify(SyslogIF syslog, int facility, int level, String message);
|
public String modify(SyslogIF syslog, int facility, int level, String message);
|
||||||
|
|
||||||
public boolean verify(String message);
|
public boolean verify(String message);
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogMessageProcessorIF provides an extensible interface for writing custom
|
* SyslogMessageProcessorIF provides an extensible interface for writing custom
|
||||||
* Syslog4j message processors.
|
* Syslog4j message processors.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogMessageProcessorIF.java,v 1.4 2010/11/28 04:15:18 cvs Exp $
|
* @version $Id: SyslogMessageProcessorIF.java,v 1.4 2010/11/28 04:15:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogMessageProcessorIF extends Serializable {
|
public interface SyslogMessageProcessorIF extends Serializable {
|
||||||
public String createSyslogHeader(int facility, int level, String localName, boolean sendLocalTimestamp, boolean sendLocalName);
|
public String createSyslogHeader(int facility, int level, String localName, boolean sendLocalTimestamp, boolean sendLocalName);
|
||||||
|
|
||||||
|
@ -3,50 +3,62 @@ package org.graylog2.syslog4j;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogPoolConfigIF is an interface which provides configuration support
|
* SyslogPoolConfigIF is an interface which provides configuration support
|
||||||
* for the Apache Commons Pool.
|
* for the Apache Commons Pool.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogPoolConfigIF.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SyslogPoolConfigIF.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogPoolConfigIF extends Serializable {
|
public interface SyslogPoolConfigIF extends Serializable {
|
||||||
public int getMaxActive();
|
public int getMaxActive();
|
||||||
|
|
||||||
public void setMaxActive(int maxActive);
|
public void setMaxActive(int maxActive);
|
||||||
|
|
||||||
public int getMaxIdle();
|
public int getMaxIdle();
|
||||||
|
|
||||||
public void setMaxIdle(int maxIdle);
|
public void setMaxIdle(int maxIdle);
|
||||||
|
|
||||||
public long getMaxWait();
|
public long getMaxWait();
|
||||||
|
|
||||||
public void setMaxWait(long maxWait);
|
public void setMaxWait(long maxWait);
|
||||||
|
|
||||||
public long getMinEvictableIdleTimeMillis();
|
public long getMinEvictableIdleTimeMillis();
|
||||||
|
|
||||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis);
|
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis);
|
||||||
|
|
||||||
public int getMinIdle();
|
public int getMinIdle();
|
||||||
|
|
||||||
public void setMinIdle(int minIdle);
|
public void setMinIdle(int minIdle);
|
||||||
|
|
||||||
public int getNumTestsPerEvictionRun();
|
public int getNumTestsPerEvictionRun();
|
||||||
|
|
||||||
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);
|
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);
|
||||||
|
|
||||||
public long getSoftMinEvictableIdleTimeMillis();
|
public long getSoftMinEvictableIdleTimeMillis();
|
||||||
|
|
||||||
public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis);
|
public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis);
|
||||||
|
|
||||||
public boolean isTestOnBorrow();
|
public boolean isTestOnBorrow();
|
||||||
|
|
||||||
public void setTestOnBorrow(boolean testOnBorrow);
|
public void setTestOnBorrow(boolean testOnBorrow);
|
||||||
|
|
||||||
public boolean isTestOnReturn();
|
public boolean isTestOnReturn();
|
||||||
|
|
||||||
public void setTestOnReturn(boolean testOnReturn);
|
public void setTestOnReturn(boolean testOnReturn);
|
||||||
|
|
||||||
public boolean isTestWhileIdle();
|
public boolean isTestWhileIdle();
|
||||||
|
|
||||||
public void setTestWhileIdle(boolean testWhileIdle);
|
public void setTestWhileIdle(boolean testWhileIdle);
|
||||||
|
|
||||||
public long getTimeBetweenEvictionRunsMillis();
|
public long getTimeBetweenEvictionRunsMillis();
|
||||||
|
|
||||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis);
|
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis);
|
||||||
|
|
||||||
public byte getWhenExhaustedAction();
|
public byte getWhenExhaustedAction();
|
||||||
|
|
||||||
public void setWhenExhaustedAction(byte whenExhaustedAction);
|
public void setWhenExhaustedAction(byte whenExhaustedAction);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package org.graylog2.syslog4j;
|
package org.graylog2.syslog4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogRuntimeException provides an extension of RuntimeException thrown
|
* SyslogRuntimeException provides an extension of RuntimeException thrown
|
||||||
* by the majority of the classes within Syslog4j.
|
* by the majority of the classes within Syslog4j.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogRuntimeException.java,v 1.3 2008/11/13 14:48:36 cvs Exp $
|
* @version $Id: SyslogRuntimeException.java,v 1.3 2008/11/13 14:48:36 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SyslogRuntimeException extends RuntimeException {
|
public class SyslogRuntimeException extends RuntimeException {
|
||||||
private static final long serialVersionUID = 7278123987654320379L;
|
private static final long serialVersionUID = 7278123987654320379L;
|
||||||
|
|
||||||
|
@ -17,15 +17,15 @@ import org.graylog2.syslog4j.impl.message.structured.StructuredSyslogMessageIF;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslog provides a base abstract implementation of the SyslogIF.
|
* AbstractSyslog provides a base abstract implementation of the SyslogIF.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslog.java,v 1.29 2011/01/11 04:58:52 cvs Exp $
|
* @version $Id: AbstractSyslog.java,v 1.29 2011/01/11 04:58:52 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslog implements SyslogIF {
|
public abstract class AbstractSyslog implements SyslogIF {
|
||||||
private static final long serialVersionUID = 2632017043774808264L;
|
private static final long serialVersionUID = 2632017043774808264L;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
protected List notifiedBackLogHandlers = new ArrayList();
|
protected List notifiedBackLogHandlers = new ArrayList();
|
||||||
|
|
||||||
protected boolean getBackLogStatus() {
|
protected boolean getBackLogStatus() {
|
||||||
synchronized(this.backLogStatusSyncObject) {
|
synchronized (this.backLogStatusSyncObject) {
|
||||||
return this.backLogStatus;
|
return this.backLogStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,9 +52,9 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
*/
|
*/
|
||||||
public void setBackLogStatus(boolean backLogStatus) {
|
public void setBackLogStatus(boolean backLogStatus) {
|
||||||
if (this.backLogStatus != backLogStatus) {
|
if (this.backLogStatus != backLogStatus) {
|
||||||
synchronized(this.backLogStatusSyncObject) {
|
synchronized (this.backLogStatusSyncObject) {
|
||||||
if (!backLogStatus) {
|
if (!backLogStatus) {
|
||||||
for(int i=0; i<this.notifiedBackLogHandlers.size(); i++) {
|
for (int i = 0; i < this.notifiedBackLogHandlers.size(); i++) {
|
||||||
SyslogBackLogHandlerIF backLogHandler = (SyslogBackLogHandlerIF) this.notifiedBackLogHandlers.get(i);
|
SyslogBackLogHandlerIF backLogHandler = (SyslogBackLogHandlerIF) this.notifiedBackLogHandlers.get(i);
|
||||||
|
|
||||||
backLogHandler.up(this);
|
backLogHandler.up(this);
|
||||||
@ -115,91 +115,91 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
|
|
||||||
public void log(int level, String message) {
|
public void log(int level, String message) {
|
||||||
if (this.syslogConfig.isUseStructuredData()) {
|
if (this.syslogConfig.isUseStructuredData()) {
|
||||||
StructuredSyslogMessageIF structuredMessage = new StructuredSyslogMessage(null,null,message);
|
StructuredSyslogMessageIF structuredMessage = new StructuredSyslogMessage(null, null, message);
|
||||||
|
|
||||||
log(getStructuredMessageProcessor(),level,structuredMessage.createMessage());
|
log(getStructuredMessageProcessor(), level, structuredMessage.createMessage());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log(getMessageProcessor(),level,message);
|
log(getMessageProcessor(), level, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(int level, SyslogMessageIF message) {
|
public void log(int level, SyslogMessageIF message) {
|
||||||
if (message instanceof StructuredSyslogMessageIF) {
|
if (message instanceof StructuredSyslogMessageIF) {
|
||||||
if (getMessageProcessor() instanceof StructuredSyslogMessageProcessor) {
|
if (getMessageProcessor() instanceof StructuredSyslogMessageProcessor) {
|
||||||
log(getMessageProcessor(),level,message.createMessage());
|
log(getMessageProcessor(), level, message.createMessage());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log(getStructuredMessageProcessor(),level,message.createMessage());
|
log(getStructuredMessageProcessor(), level, message.createMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log(getMessageProcessor(),level,message.createMessage());
|
log(getMessageProcessor(), level, message.createMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
log(LEVEL_DEBUG,message);
|
log(LEVEL_DEBUG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notice(String message) {
|
public void notice(String message) {
|
||||||
log(LEVEL_NOTICE,message);
|
log(LEVEL_NOTICE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String message) {
|
public void info(String message) {
|
||||||
log(LEVEL_INFO,message);
|
log(LEVEL_INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(String message) {
|
public void warn(String message) {
|
||||||
log(LEVEL_WARN,message);
|
log(LEVEL_WARN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(String message) {
|
public void error(String message) {
|
||||||
log(LEVEL_ERROR,message);
|
log(LEVEL_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void critical(String message) {
|
public void critical(String message) {
|
||||||
log(LEVEL_CRITICAL,message);
|
log(LEVEL_CRITICAL, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alert(String message) {
|
public void alert(String message) {
|
||||||
log(LEVEL_ALERT,message);
|
log(LEVEL_ALERT, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void emergency(String message) {
|
public void emergency(String message) {
|
||||||
log(LEVEL_EMERGENCY,message);
|
log(LEVEL_EMERGENCY, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(SyslogMessageIF message) {
|
public void debug(SyslogMessageIF message) {
|
||||||
log(LEVEL_DEBUG,message);
|
log(LEVEL_DEBUG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notice(SyslogMessageIF message) {
|
public void notice(SyslogMessageIF message) {
|
||||||
log(LEVEL_NOTICE,message);
|
log(LEVEL_NOTICE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(SyslogMessageIF message) {
|
public void info(SyslogMessageIF message) {
|
||||||
log(LEVEL_INFO,message);
|
log(LEVEL_INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(SyslogMessageIF message) {
|
public void warn(SyslogMessageIF message) {
|
||||||
log(LEVEL_WARN,message);
|
log(LEVEL_WARN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(SyslogMessageIF message) {
|
public void error(SyslogMessageIF message) {
|
||||||
log(LEVEL_ERROR,message);
|
log(LEVEL_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void critical(SyslogMessageIF message) {
|
public void critical(SyslogMessageIF message) {
|
||||||
log(LEVEL_CRITICAL,message);
|
log(LEVEL_CRITICAL, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alert(SyslogMessageIF message) {
|
public void alert(SyslogMessageIF message) {
|
||||||
log(LEVEL_ALERT,message);
|
log(LEVEL_ALERT, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void emergency(SyslogMessageIF message) {
|
public void emergency(SyslogMessageIF message) {
|
||||||
log(LEVEL_EMERGENCY,message);
|
log(LEVEL_EMERGENCY, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String prefixMessage(String message, String suffix) {
|
protected String prefixMessage(String message, String suffix) {
|
||||||
@ -214,23 +214,23 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
String _message = null;
|
String _message = null;
|
||||||
|
|
||||||
if (this.syslogConfig.isIncludeIdentInMessageModifier()) {
|
if (this.syslogConfig.isIncludeIdentInMessageModifier()) {
|
||||||
_message = prefixMessage(message,IDENT_SUFFIX_DEFAULT);
|
_message = prefixMessage(message, IDENT_SUFFIX_DEFAULT);
|
||||||
_message = modifyMessage(level,_message);
|
_message = modifyMessage(level, _message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_message = modifyMessage(level,message);
|
_message = modifyMessage(level, message);
|
||||||
_message = prefixMessage(_message,IDENT_SUFFIX_DEFAULT);
|
_message = prefixMessage(_message, IDENT_SUFFIX_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
write(messageProcessor, level,_message);
|
write(messageProcessor, level, _message);
|
||||||
|
|
||||||
} catch (SyslogRuntimeException sre) {
|
} catch (SyslogRuntimeException sre) {
|
||||||
if (sre.getCause() != null) {
|
if (sre.getCause() != null) {
|
||||||
backLog(level,_message,sre.getCause());
|
backLog(level, _message, sre.getCause());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
backLog(level,_message,sre);
|
backLog(level, _message, sre);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.syslogConfig.isThrowExceptionOnWrite()) {
|
if (this.syslogConfig.isThrowExceptionOnWrite()) {
|
||||||
@ -240,10 +240,10 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void write(SyslogMessageProcessorIF messageProcessor, int level, String message) throws SyslogRuntimeException {
|
protected void write(SyslogMessageProcessorIF messageProcessor, int level, String message) throws SyslogRuntimeException {
|
||||||
String header = messageProcessor.createSyslogHeader(this.syslogConfig.getFacility(),level,this.syslogConfig.getLocalName(),this.syslogConfig.isSendLocalTimestamp(),this.syslogConfig.isSendLocalName());
|
String header = messageProcessor.createSyslogHeader(this.syslogConfig.getFacility(), level, this.syslogConfig.getLocalName(), this.syslogConfig.isSendLocalTimestamp(), this.syslogConfig.isSendLocalName());
|
||||||
|
|
||||||
byte[] h = SyslogUtility.getBytes(this.syslogConfig,header);
|
byte[] h = SyslogUtility.getBytes(this.syslogConfig, header);
|
||||||
byte[] m = SyslogUtility.getBytes(this.syslogConfig,message);
|
byte[] m = SyslogUtility.getBytes(this.syslogConfig, message);
|
||||||
|
|
||||||
int mLength = m.length;
|
int mLength = m.length;
|
||||||
|
|
||||||
@ -256,9 +256,9 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mLength <= availableLen) {
|
if (mLength <= availableLen) {
|
||||||
byte[] data = messageProcessor.createPacketData(h,m,0,mLength);
|
byte[] data = messageProcessor.createPacketData(h, m, 0, mLength);
|
||||||
|
|
||||||
write(level,data);
|
write(level, data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
byte[] splitBeginText = this.syslogConfig.getSplitMessageBeginText();
|
byte[] splitBeginText = this.syslogConfig.getSplitMessageBeginText();
|
||||||
@ -267,7 +267,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
int left = mLength;
|
int left = mLength;
|
||||||
|
|
||||||
while(left > 0) {
|
while (left > 0) {
|
||||||
boolean firstTime = (pos == 0);
|
boolean firstTime = (pos == 0);
|
||||||
|
|
||||||
boolean doSplitBeginText = splitBeginText != null && !firstTime;
|
boolean doSplitBeginText = splitBeginText != null && !firstTime;
|
||||||
@ -286,9 +286,9 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
throw new SyslogRuntimeException("Message length < 0; recommendation: increase the size of maxMessageLength");
|
throw new SyslogRuntimeException("Message length < 0; recommendation: increase the size of maxMessageLength");
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = messageProcessor.createPacketData(h,m,pos,actualAvailableLen,doSplitBeginText ? splitBeginText : null,doSplitEndText ? splitEndText : null);
|
byte[] data = messageProcessor.createPacketData(h, m, pos, actualAvailableLen, doSplitBeginText ? splitBeginText : null, doSplitEndText ? splitEndText : null);
|
||||||
|
|
||||||
write(level,data);
|
write(level, data);
|
||||||
|
|
||||||
pos += actualAvailableLen;
|
pos += actualAvailableLen;
|
||||||
left -= actualAvailableLen;
|
left -= actualAvailableLen;
|
||||||
@ -311,7 +311,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
|
|
||||||
int facility = this.syslogConfig.getFacility();
|
int facility = this.syslogConfig.getFacility();
|
||||||
|
|
||||||
for(int i=0; i<_messageModifiers.size(); i++) {
|
for (int i = 0; i < _messageModifiers.size(); i++) {
|
||||||
SyslogMessageModifierIF messageModifier = (SyslogMessageModifierIF) _messageModifiers.get(i);
|
SyslogMessageModifierIF messageModifier = (SyslogMessageModifierIF) _messageModifiers.get(i);
|
||||||
|
|
||||||
_message = messageModifier.modify(this, facility, level, _message);
|
_message = messageModifier.modify(this, facility, level, _message);
|
||||||
@ -321,7 +321,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void backLog(int level, String message, Throwable reasonThrowable) {
|
public void backLog(int level, String message, Throwable reasonThrowable) {
|
||||||
backLog(level,message,reasonThrowable != null ? reasonThrowable.toString() : "UNKNOWN");
|
backLog(level, message, reasonThrowable != null ? reasonThrowable.toString() : "UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void backLog(int level, String message, String reason) {
|
public void backLog(int level, String message, String reason) {
|
||||||
@ -333,7 +333,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
|
|
||||||
List backLogHandlers = this.syslogConfig.getBackLogHandlers();
|
List backLogHandlers = this.syslogConfig.getBackLogHandlers();
|
||||||
|
|
||||||
for(int i=0; i<backLogHandlers.size(); i++) {
|
for (int i = 0; i < backLogHandlers.size(); i++) {
|
||||||
SyslogBackLogHandlerIF backLogHandler = (SyslogBackLogHandlerIF) backLogHandlers.get(i);
|
SyslogBackLogHandlerIF backLogHandler = (SyslogBackLogHandlerIF) backLogHandlers.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -342,7 +342,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
this.notifiedBackLogHandlers.add(backLogHandler);
|
this.notifiedBackLogHandlers.add(backLogHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
backLogHandler.log(this,level,message,reason);
|
backLogHandler.log(this, level, message, reason);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -369,7 +369,7 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AbstractSyslogWriter createWriter(){
|
public AbstractSyslogWriter createWriter() {
|
||||||
Class clazz = this.syslogConfig.getSyslogWriterClass();
|
Class clazz = this.syslogConfig.getSyslogWriterClass();
|
||||||
|
|
||||||
AbstractSyslogWriter newWriter = null;
|
AbstractSyslogWriter newWriter = null;
|
||||||
|
@ -10,16 +10,16 @@ import org.graylog2.syslog4j.impl.backlog.printstream.SystemErrSyslogBackLogHand
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslog provides a base abstract implementation of the SyslogConfigIF
|
* AbstractSyslog provides a base abstract implementation of the SyslogConfigIF
|
||||||
* configuration interface.
|
* configuration interface.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogConfig.java,v 1.24 2010/11/28 04:43:31 cvs Exp $
|
* @version $Id: AbstractSyslogConfig.java,v 1.24 2010/11/28 04:43:31 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
||||||
private static final long serialVersionUID = -3728308557871358111L;
|
private static final long serialVersionUID = -3728308557871358111L;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSplitMessageBeginText(String splitMessageBeginText) throws SyslogRuntimeException {
|
public void setSplitMessageBeginText(String splitMessageBeginText) throws SyslogRuntimeException {
|
||||||
this.splitMessageBeginText = SyslogUtility.getBytes(this,splitMessageBeginText);
|
this.splitMessageBeginText = SyslogUtility.getBytes(this, splitMessageBeginText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getSplitMessageEndText() {
|
public byte[] getSplitMessageEndText() {
|
||||||
@ -117,7 +117,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSplitMessageEndText(String splitMessageEndText) throws SyslogRuntimeException {
|
public void setSplitMessageEndText(String splitMessageEndText) throws SyslogRuntimeException {
|
||||||
this.splitMessageEndText = SyslogUtility.getBytes(this,splitMessageEndText);
|
this.splitMessageEndText = SyslogUtility.getBytes(this, splitMessageEndText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxMessageLength() {
|
public int getMaxMessageLength() {
|
||||||
@ -179,7 +179,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
|
|
||||||
List _messageModifiers = _getMessageModifiers();
|
List _messageModifiers = _getMessageModifiers();
|
||||||
|
|
||||||
synchronized(_messageModifiers) {
|
synchronized (_messageModifiers) {
|
||||||
_messageModifiers.add(messageModifier);
|
_messageModifiers.add(messageModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,9 +191,9 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
|
|
||||||
List _messageModifiers = _getMessageModifiers();
|
List _messageModifiers = _getMessageModifiers();
|
||||||
|
|
||||||
synchronized(_messageModifiers) {
|
synchronized (_messageModifiers) {
|
||||||
try {
|
try {
|
||||||
_messageModifiers.add(index,messageModifier);
|
_messageModifiers.add(index, messageModifier);
|
||||||
|
|
||||||
} catch (IndexOutOfBoundsException ioobe) {
|
} catch (IndexOutOfBoundsException ioobe) {
|
||||||
throw new SyslogRuntimeException(ioobe);
|
throw new SyslogRuntimeException(ioobe);
|
||||||
@ -208,7 +208,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
|
|
||||||
List _messageModifiers = _getMessageModifiers();
|
List _messageModifiers = _getMessageModifiers();
|
||||||
|
|
||||||
synchronized(_messageModifiers) {
|
synchronized (_messageModifiers) {
|
||||||
_messageModifiers.remove(messageModifier);
|
_messageModifiers.remove(messageModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
|
|
||||||
List _backLogHandlers = _getBackLogHandlers();
|
List _backLogHandlers = _getBackLogHandlers();
|
||||||
|
|
||||||
synchronized(_backLogHandlers) {
|
synchronized (_backLogHandlers) {
|
||||||
backLogHandler.initialize();
|
backLogHandler.initialize();
|
||||||
_backLogHandlers.add(backLogHandler);
|
_backLogHandlers.add(backLogHandler);
|
||||||
}
|
}
|
||||||
@ -257,10 +257,10 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
|
|
||||||
List _backLogHandlers = _getBackLogHandlers();
|
List _backLogHandlers = _getBackLogHandlers();
|
||||||
|
|
||||||
synchronized(_backLogHandlers) {
|
synchronized (_backLogHandlers) {
|
||||||
try {
|
try {
|
||||||
backLogHandler.initialize();
|
backLogHandler.initialize();
|
||||||
_backLogHandlers.add(index,backLogHandler);
|
_backLogHandlers.add(index, backLogHandler);
|
||||||
|
|
||||||
} catch (IndexOutOfBoundsException ioobe) {
|
} catch (IndexOutOfBoundsException ioobe) {
|
||||||
throw new SyslogRuntimeException(ioobe);
|
throw new SyslogRuntimeException(ioobe);
|
||||||
@ -275,7 +275,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
|
|||||||
|
|
||||||
List _backLogHandlers = _getBackLogHandlers();
|
List _backLogHandlers = _getBackLogHandlers();
|
||||||
|
|
||||||
synchronized(_backLogHandlers) {
|
synchronized (_backLogHandlers) {
|
||||||
_backLogHandlers.remove(backLogHandler);
|
_backLogHandlers.remove(backLogHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import java.util.List;
|
|||||||
import org.graylog2.syslog4j.SyslogConfigIF;
|
import org.graylog2.syslog4j.SyslogConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogConfigIF provides an interface for all Abstract Syslog
|
* AbstractSyslogConfigIF provides an interface for all Abstract Syslog
|
||||||
* configuration implementations.
|
* configuration implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogConfigIF.java,v 1.7 2010/10/29 03:14:20 cvs Exp $
|
* @version $Id: AbstractSyslogConfigIF.java,v 1.7 2010/10/29 03:14:20 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface AbstractSyslogConfigIF extends SyslogConfigIF {
|
public interface AbstractSyslogConfigIF extends SyslogConfigIF {
|
||||||
public Class getSyslogWriterClass();
|
public Class getSyslogWriterClass();
|
||||||
|
|
||||||
@ -23,30 +23,39 @@ public interface AbstractSyslogConfigIF extends SyslogConfigIF {
|
|||||||
public List getMessageModifiers();
|
public List getMessageModifiers();
|
||||||
|
|
||||||
public byte[] getSplitMessageBeginText();
|
public byte[] getSplitMessageBeginText();
|
||||||
|
|
||||||
public void setSplitMessageBeginText(byte[] beginText);
|
public void setSplitMessageBeginText(byte[] beginText);
|
||||||
|
|
||||||
public byte[] getSplitMessageEndText();
|
public byte[] getSplitMessageEndText();
|
||||||
|
|
||||||
public void setSplitMessageEndText(byte[] endText);
|
public void setSplitMessageEndText(byte[] endText);
|
||||||
|
|
||||||
public boolean isThreaded();
|
public boolean isThreaded();
|
||||||
|
|
||||||
public void setThreaded(boolean threaded);
|
public void setThreaded(boolean threaded);
|
||||||
|
|
||||||
public boolean isUseDaemonThread();
|
public boolean isUseDaemonThread();
|
||||||
|
|
||||||
public void setUseDaemonThread(boolean useDaemonThread);
|
public void setUseDaemonThread(boolean useDaemonThread);
|
||||||
|
|
||||||
public int getThreadPriority();
|
public int getThreadPriority();
|
||||||
|
|
||||||
public void setThreadPriority(int threadPriority);
|
public void setThreadPriority(int threadPriority);
|
||||||
|
|
||||||
public long getThreadLoopInterval();
|
public long getThreadLoopInterval();
|
||||||
|
|
||||||
public void setThreadLoopInterval(long threadLoopInterval);
|
public void setThreadLoopInterval(long threadLoopInterval);
|
||||||
|
|
||||||
public long getMaxShutdownWait();
|
public long getMaxShutdownWait();
|
||||||
|
|
||||||
public void setMaxShutdownWait(long maxShutdownWait);
|
public void setMaxShutdownWait(long maxShutdownWait);
|
||||||
|
|
||||||
public int getWriteRetries();
|
public int getWriteRetries();
|
||||||
|
|
||||||
public void setWriteRetries(int writeRetries);
|
public void setWriteRetries(int writeRetries);
|
||||||
|
|
||||||
public int getMaxQueueSize();
|
public int getMaxQueueSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the (default) value of -1 to allow for a queue of indefinite depth (size).
|
* Use the (default) value of -1 to allow for a queue of indefinite depth (size).
|
||||||
*
|
*
|
||||||
|
@ -9,19 +9,19 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogWriter is an implementation of Runnable that supports sending
|
* AbstractSyslogWriter is an implementation of Runnable that supports sending
|
||||||
* syslog messages within a separate Thread or an object pool.
|
* syslog messages within a separate Thread or an object pool.
|
||||||
*
|
* <p/>
|
||||||
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
|
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
|
||||||
* a queuing mechanism is used (via LinkedList).</p>
|
* a queuing mechanism is used (via LinkedList).</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogWriter.java,v 1.9 2010/10/25 03:50:25 cvs Exp $
|
* @version $Id: AbstractSyslogWriter.java,v 1.9 2010/10/25 03:50:25 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogWriter implements Runnable, Serializable {
|
public abstract class AbstractSyslogWriter implements Runnable, Serializable {
|
||||||
private static final long serialVersionUID = 836468466009035847L;
|
private static final long serialVersionUID = 836468466009035847L;
|
||||||
|
|
||||||
@ -51,12 +51,12 @@ public abstract class AbstractSyslogWriter implements Runnable, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void queue(int level, byte[] message) {
|
public void queue(int level, byte[] message) {
|
||||||
synchronized(this.queuedMessages) {
|
synchronized (this.queuedMessages) {
|
||||||
if (this.syslogConfig.getMaxQueueSize() == -1 || this.queuedMessages.size() < this.syslogConfig.getMaxQueueSize()) {
|
if (this.syslogConfig.getMaxQueueSize() == -1 || this.queuedMessages.size() < this.syslogConfig.getMaxQueueSize()) {
|
||||||
this.queuedMessages.add(message);
|
this.queuedMessages.add(message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.syslog.backLog(level,SyslogUtility.newString(syslogConfig,message),"MaxQueueSize (" + this.syslogConfig.getMaxQueueSize() + ") reached");
|
this.syslog.backLog(level, SyslogUtility.newString(syslogConfig, message), "MaxQueueSize (" + this.syslogConfig.getMaxQueueSize() + ") reached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,16 +78,16 @@ public abstract class AbstractSyslogWriter implements Runnable, Serializable {
|
|||||||
protected abstract void runCompleted();
|
protected abstract void runCompleted();
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
while(!this.shutdown || !this.queuedMessages.isEmpty()) {
|
while (!this.shutdown || !this.queuedMessages.isEmpty()) {
|
||||||
List queuedMessagesCopy = null;
|
List queuedMessagesCopy = null;
|
||||||
|
|
||||||
synchronized(this.queuedMessages) {
|
synchronized (this.queuedMessages) {
|
||||||
queuedMessagesCopy = new LinkedList(this.queuedMessages);
|
queuedMessagesCopy = new LinkedList(this.queuedMessages);
|
||||||
this.queuedMessages.clear();
|
this.queuedMessages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queuedMessagesCopy != null) {
|
if (queuedMessagesCopy != null) {
|
||||||
while(!queuedMessagesCopy.isEmpty()) {
|
while (!queuedMessagesCopy.isEmpty()) {
|
||||||
byte[] message = (byte[]) queuedMessagesCopy.remove(0);
|
byte[] message = (byte[]) queuedMessagesCopy.remove(0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -96,7 +96,7 @@ public abstract class AbstractSyslogWriter implements Runnable, Serializable {
|
|||||||
this.syslog.setBackLogStatus(false);
|
this.syslog.setBackLogStatus(false);
|
||||||
|
|
||||||
} catch (SyslogRuntimeException sre) {
|
} catch (SyslogRuntimeException sre) {
|
||||||
this.syslog.backLog(SyslogConstants.LEVEL_INFO,SyslogUtility.newString(this.syslog.getConfig(),message),sre);
|
this.syslog.backLog(SyslogConstants.LEVEL_INFO, SyslogUtility.newString(this.syslog.getConfig(), message), sre);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,17 @@ import org.graylog2.syslog4j.SyslogIF;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogBackLogHandler is an implementation of SyslogBackLogHandlerIF
|
* AbstractSyslogBackLogHandler is an implementation of SyslogBackLogHandlerIF
|
||||||
* that mainly provides the helpful "combine" method for handling the "reason"
|
* that mainly provides the helpful "combine" method for handling the "reason"
|
||||||
* why a BackLog has occurred.
|
* why a BackLog has occurred.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
|
* @version $Id: AbstractSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogBackLogHandler implements SyslogBackLogHandlerIF {
|
public abstract class AbstractSyslogBackLogHandler implements SyslogBackLogHandlerIF {
|
||||||
protected boolean appendReason = true;
|
protected boolean appendReason = true;
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
|
|||||||
import org.graylog2.syslog4j.SyslogIF;
|
import org.graylog2.syslog4j.SyslogIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NullSyslogBackLogHandler can be used if there's no need for a last-chance
|
* NullSyslogBackLogHandler can be used if there's no need for a last-chance
|
||||||
* logging mechanism whenever the Syslog protocol fails.
|
* logging mechanism whenever the Syslog protocol fails.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: NullSyslogBackLogHandler.java,v 1.2 2010/10/25 03:50:25 cvs Exp $
|
* @version $Id: NullSyslogBackLogHandler.java,v 1.2 2010/10/25 03:50:25 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class NullSyslogBackLogHandler implements SyslogBackLogHandlerIF {
|
public class NullSyslogBackLogHandler implements SyslogBackLogHandlerIF {
|
||||||
public static final NullSyslogBackLogHandler INSTANCE = new NullSyslogBackLogHandler();
|
public static final NullSyslogBackLogHandler INSTANCE = new NullSyslogBackLogHandler();
|
||||||
|
|
||||||
|
@ -6,16 +6,16 @@ import org.graylog2.syslog4j.SyslogIF;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syslog4jBackLogHandler is used to send Syslog backLog messages to
|
* Syslog4jBackLogHandler is used to send Syslog backLog messages to
|
||||||
* another Syslog4j protocol whenever the main Syslog protocol fails.
|
* another Syslog4j protocol whenever the main Syslog protocol fails.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: Syslog4jBackLogHandler.java,v 1.1 2009/07/25 18:42:47 cvs Exp $
|
* @version $Id: Syslog4jBackLogHandler.java,v 1.1 2009/07/25 18:42:47 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class Syslog4jBackLogHandler extends AbstractSyslogBackLogHandler {
|
public class Syslog4jBackLogHandler extends AbstractSyslogBackLogHandler {
|
||||||
protected SyslogIF syslog = null;
|
protected SyslogIF syslog = null;
|
||||||
protected int downLevel = SyslogConstants.LEVEL_WARN;
|
protected int downLevel = SyslogConstants.LEVEL_WARN;
|
||||||
@ -48,20 +48,20 @@ public class Syslog4jBackLogHandler extends AbstractSyslogBackLogHandler {
|
|||||||
throw new SyslogRuntimeException("Ignoring this log entry since the backLog protocol \"" + this.syslog.getProtocol() + "\" is the same as the main protocol");
|
throw new SyslogRuntimeException("Ignoring this log entry since the backLog protocol \"" + this.syslog.getProtocol() + "\" is the same as the main protocol");
|
||||||
}
|
}
|
||||||
|
|
||||||
String combinedMessage = combine(syslog,level,message,reason);
|
String combinedMessage = combine(syslog, level, message, reason);
|
||||||
|
|
||||||
this.syslog.log(level,combinedMessage);
|
this.syslog.log(level, combinedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void down(SyslogIF syslog, String reason) {
|
public void down(SyslogIF syslog, String reason) {
|
||||||
if (!this.syslog.getProtocol().equals(syslog.getProtocol())) {
|
if (!this.syslog.getProtocol().equals(syslog.getProtocol())) {
|
||||||
this.syslog.log(this.downLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
|
this.syslog.log(this.downLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void up(SyslogIF syslog) {
|
public void up(SyslogIF syslog) {
|
||||||
if (!this.syslog.getProtocol().equals(syslog.getProtocol())) {
|
if (!this.syslog.getProtocol().equals(syslog.getProtocol())) {
|
||||||
this.syslog.log(this.downLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is up");
|
this.syslog.log(this.downLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is up");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.impl.backlog.AbstractSyslogBackLogHandler;
|
import org.graylog2.syslog4j.impl.backlog.AbstractSyslogBackLogHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log4jSyslogBackLogHandler is used to send Syslog backLog messages to
|
* Log4jSyslogBackLogHandler is used to send Syslog backLog messages to
|
||||||
* Log4j whenever the Syslog protocol fails.
|
* Log4j whenever the Syslog protocol fails.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: Log4jSyslogBackLogHandler.java,v 1.2 2009/07/22 15:54:23 cvs Exp $
|
* @version $Id: Log4jSyslogBackLogHandler.java,v 1.2 2009/07/22 15:54:23 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
||||||
protected Logger logger = null;
|
protected Logger logger = null;
|
||||||
protected Level downLevel = Level.WARN;
|
protected Level downLevel = Level.WARN;
|
||||||
@ -88,7 +88,7 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
|||||||
throw new SyslogRuntimeException("loggerFactory cannot be null");
|
throw new SyslogRuntimeException("loggerFactory cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger = Logger.getLogger(loggerName,loggerFactory);
|
this.logger = Logger.getLogger(loggerName, loggerFactory);
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
|||||||
throw new SyslogRuntimeException("loggerFactory cannot be null");
|
throw new SyslogRuntimeException("loggerFactory cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger = Logger.getLogger(loggerName,loggerFactory);
|
this.logger = Logger.getLogger(loggerName, loggerFactory);
|
||||||
this.appendReason = appendReason;
|
this.appendReason = appendReason;
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
@ -115,15 +115,23 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static Level getLog4jLevel(int level) {
|
protected static Level getLog4jLevel(int level) {
|
||||||
switch(level) {
|
switch (level) {
|
||||||
case SyslogConstants.LEVEL_DEBUG: return Level.DEBUG;
|
case SyslogConstants.LEVEL_DEBUG:
|
||||||
case SyslogConstants.LEVEL_INFO: return Level.INFO;
|
return Level.DEBUG;
|
||||||
case SyslogConstants.LEVEL_NOTICE: return Level.INFO;
|
case SyslogConstants.LEVEL_INFO:
|
||||||
case SyslogConstants.LEVEL_WARN: return Level.WARN;
|
return Level.INFO;
|
||||||
case SyslogConstants.LEVEL_ERROR: return Level.ERROR;
|
case SyslogConstants.LEVEL_NOTICE:
|
||||||
case SyslogConstants.LEVEL_CRITICAL: return Level.ERROR;
|
return Level.INFO;
|
||||||
case SyslogConstants.LEVEL_ALERT: return Level.ERROR;
|
case SyslogConstants.LEVEL_WARN:
|
||||||
case SyslogConstants.LEVEL_EMERGENCY: return Level.FATAL;
|
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:
|
default:
|
||||||
return Level.WARN;
|
return Level.WARN;
|
||||||
@ -131,18 +139,18 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void down(SyslogIF syslog, String reason) {
|
public void down(SyslogIF syslog, String reason) {
|
||||||
this.logger.log(this.downLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
|
this.logger.log(this.downLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void up(SyslogIF syslog) {
|
public void up(SyslogIF syslog) {
|
||||||
this.logger.log(this.upLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is up");
|
this.logger.log(this.upLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is up");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(SyslogIF syslog, int level, String message, String reason) throws SyslogRuntimeException {
|
public void log(SyslogIF syslog, int level, String message, String reason) throws SyslogRuntimeException {
|
||||||
Level log4jLevel = getLog4jLevel(level);
|
Level log4jLevel = getLog4jLevel(level);
|
||||||
|
|
||||||
String combinedMessage = combine(syslog,level,message,reason);
|
String combinedMessage = combine(syslog, level, message, reason);
|
||||||
|
|
||||||
this.logger.log(log4jLevel,combinedMessage);
|
this.logger.log(log4jLevel, combinedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.impl.backlog.AbstractSyslogBackLogHandler;
|
import org.graylog2.syslog4j.impl.backlog.AbstractSyslogBackLogHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PrintStreamSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
|
* PrintStreamSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
|
||||||
* (for whatever reason) within the rest of Syslog to a PrintStream.
|
* (for whatever reason) within the rest of Syslog to a PrintStream.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PrintStreamSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
|
* @version $Id: PrintStreamSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PrintStreamSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
public class PrintStreamSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
|
||||||
protected PrintStream printStream = null;
|
protected PrintStream printStream = null;
|
||||||
protected boolean appendLinefeed = false;
|
protected boolean appendLinefeed = false;
|
||||||
@ -57,7 +57,7 @@ public class PrintStreamSyslogBackLogHandler extends AbstractSyslogBackLogHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void log(SyslogIF syslog, int level, String message, String reason) {
|
public void log(SyslogIF syslog, int level, String message, String reason) {
|
||||||
String combinedMessage = combine(syslog,level,message,reason);
|
String combinedMessage = combine(syslog, level, message, reason);
|
||||||
|
|
||||||
if (this.appendLinefeed) {
|
if (this.appendLinefeed) {
|
||||||
this.printStream.println(combinedMessage);
|
this.printStream.println(combinedMessage);
|
||||||
|
@ -3,25 +3,26 @@ package org.graylog2.syslog4j.impl.backlog.printstream;
|
|||||||
import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
|
import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SystemErrSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
|
* SystemErrSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
|
||||||
* (for whatever reason) within the rest of Syslog to System.err.
|
* (for whatever reason) within the rest of Syslog to System.err.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SystemErrSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
|
* @version $Id: SystemErrSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SystemErrSyslogBackLogHandler extends PrintStreamSyslogBackLogHandler {
|
public class SystemErrSyslogBackLogHandler extends PrintStreamSyslogBackLogHandler {
|
||||||
public static final SyslogBackLogHandlerIF create() {
|
public static final SyslogBackLogHandlerIF create() {
|
||||||
return new SystemErrSyslogBackLogHandler();
|
return new SystemErrSyslogBackLogHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemErrSyslogBackLogHandler() {
|
public SystemErrSyslogBackLogHandler() {
|
||||||
super(System.err,true);
|
super(System.err, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemErrSyslogBackLogHandler(boolean appendReason) {
|
public SystemErrSyslogBackLogHandler(boolean appendReason) {
|
||||||
super(System.err,true,appendReason);
|
super(System.err, true, appendReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,26 @@ package org.graylog2.syslog4j.impl.backlog.printstream;
|
|||||||
import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
|
import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SystemOutSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
|
* SystemOutSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
|
||||||
* (for whatever reason) within the rest of Syslog to System.out.
|
* (for whatever reason) within the rest of Syslog to System.out.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SystemOutSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
|
* @version $Id: SystemOutSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SystemOutSyslogBackLogHandler extends PrintStreamSyslogBackLogHandler {
|
public class SystemOutSyslogBackLogHandler extends PrintStreamSyslogBackLogHandler {
|
||||||
public static final SyslogBackLogHandlerIF create() {
|
public static final SyslogBackLogHandlerIF create() {
|
||||||
return new SystemOutSyslogBackLogHandler();
|
return new SystemOutSyslogBackLogHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemOutSyslogBackLogHandler() {
|
public SystemOutSyslogBackLogHandler() {
|
||||||
super(System.out,true);
|
super(System.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemOutSyslogBackLogHandler(boolean appendReason) {
|
public SystemOutSyslogBackLogHandler(boolean appendReason) {
|
||||||
super(System.out,true,appendReason);
|
super(System.out, true, appendReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,26 +4,26 @@ import org.apache.log4j.helpers.LogLog;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Syslog4jAppender provides a Log4j Appender wrapper for Syslog4j.
|
* Syslog4jAppender provides a Log4j Appender wrapper for Syslog4j.
|
||||||
*
|
* <p/>
|
||||||
* <p>Note: Syslog4jAppender does NOT extend Log4j's SyslogAppender.</p>
|
* <p>Note: Syslog4jAppender does NOT extend Log4j's SyslogAppender.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Example log4j.xml configuration:</p>
|
* <p>Example log4j.xml configuration:</p>
|
||||||
*
|
* <p/>
|
||||||
* <pre>
|
* <pre>
|
||||||
* <code>
|
* <code>
|
||||||
<appender name="Syslog4j" class="org.graylog2.syslog4j.impl.log4j.Syslog4jAppender">
|
* <appender name="Syslog4j" class="org.graylog2.syslog4j.impl.log4j.Syslog4jAppender">
|
||||||
<param name="Facility" value="user"/>
|
* <param name="Facility" value="user"/>
|
||||||
<param name="Protocol" value="tcp"/>
|
* <param name="Protocol" value="tcp"/>
|
||||||
<param name="Host" value="192.168.0.1"/>
|
* <param name="Host" value="192.168.0.1"/>
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
* <layout class="org.apache.log4j.PatternLayout">
|
||||||
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m"/>
|
* <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m"/>
|
||||||
</layout>
|
* </layout>
|
||||||
</appender>
|
* </appender>
|
||||||
* </code>
|
* </code>
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
* <p/>
|
||||||
* <p>All available parameters are:</p>
|
* <p>All available parameters are:</p>
|
||||||
*
|
* <p/>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>ident</li>
|
* <li>ident</li>
|
||||||
* <li>localName</li>
|
* <li>localName</li>
|
||||||
@ -42,7 +42,7 @@ import org.apache.log4j.helpers.LogLog;
|
|||||||
* <li>truncateMessage</li>
|
* <li>truncateMessage</li>
|
||||||
* <li>useStructuredData</li>
|
* <li>useStructuredData</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
|
@ -12,10 +12,10 @@ import org.graylog2.syslog4j.util.SyslogUtility;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Syslog4jAppenderSkeleton provides an extensible Log4j Appender wrapper for Syslog4j.
|
* Syslog4jAppenderSkeleton provides an extensible Log4j Appender wrapper for Syslog4j.
|
||||||
*
|
* <p/>
|
||||||
* <p>Classes which inherit Syslog4jAppenderSkeleton must implement the "initialize()" method,
|
* <p>Classes which inherit Syslog4jAppenderSkeleton must implement the "initialize()" method,
|
||||||
* which sets up Syslog4j for use by the Log4j Appender.</p>
|
* which sets up Syslog4j for use by the Log4j Appender.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
@ -134,11 +134,11 @@ public abstract class Syslog4jAppenderSkeleton extends AppenderSkeleton implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.splitMessageBeginText != null) {
|
if (this.splitMessageBeginText != null) {
|
||||||
abstractSyslogConfig.setSplitMessageBeginText(SyslogUtility.getBytes(abstractSyslogConfig,this.splitMessageBeginText));
|
abstractSyslogConfig.setSplitMessageBeginText(SyslogUtility.getBytes(abstractSyslogConfig, this.splitMessageBeginText));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.splitMessageEndText != null) {
|
if (this.splitMessageEndText != null) {
|
||||||
abstractSyslogConfig.setSplitMessageEndText(SyslogUtility.getBytes(abstractSyslogConfig,this.splitMessageEndText));
|
abstractSyslogConfig.setSplitMessageEndText(SyslogUtility.getBytes(abstractSyslogConfig, this.splitMessageEndText));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.maxShutdownWait != null && this.maxShutdownWait.length() > 0) {
|
if (this.maxShutdownWait != null && this.maxShutdownWait.length() > 0) {
|
||||||
@ -189,12 +189,12 @@ public abstract class Syslog4jAppenderSkeleton extends AppenderSkeleton implemen
|
|||||||
if (this.layout != null) {
|
if (this.layout != null) {
|
||||||
String message = this.layout.format(event);
|
String message = this.layout.format(event);
|
||||||
|
|
||||||
this.syslog.log(level,message);
|
this.syslog.log(level, message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String message = event.getRenderedMessage();
|
String message = event.getRenderedMessage();
|
||||||
|
|
||||||
this.syslog.log(level,message);
|
this.syslog.log(level, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,20 +8,20 @@ import java.util.Date;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageIF;
|
import org.graylog2.syslog4j.SyslogMessageIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogMessage provides support for turning POJO (Plain Ol'
|
* AbstractSyslogMessage provides support for turning POJO (Plain Ol'
|
||||||
* Java Objects) into Syslog messages.
|
* Java Objects) into Syslog messages.
|
||||||
*
|
* <p/>
|
||||||
* <p>More information on the PCI DSS specification is available here:</p>
|
* <p>More information on the PCI DSS specification is available here:</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
|
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogMessage.java,v 1.2 2009/04/17 02:37:04 cvs Exp $
|
* @version $Id: AbstractSyslogMessage.java,v 1.2 2009/04/17 02:37:04 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogMessage implements SyslogMessageIF {
|
public abstract class AbstractSyslogMessage implements SyslogMessageIF {
|
||||||
private static final long serialVersionUID = 414124277626756491L;
|
private static final long serialVersionUID = 414124277626756491L;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public abstract class AbstractSyslogMessageModifier implements SyslogMessageModi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String[] parseInlineModifier(String message) {
|
public String[] parseInlineModifier(String message) {
|
||||||
return parseInlineModifier(message,this.messageModifierConfig.getPrefix(),this.messageModifierConfig.getSuffix());
|
return parseInlineModifier(message, this.messageModifierConfig.getPrefix(), this.messageModifierConfig.getSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] parseInlineModifier(String message, String prefix, String suffix) {
|
public static String[] parseInlineModifier(String message, String prefix, String suffix) {
|
||||||
@ -31,17 +31,17 @@ public abstract class AbstractSyslogMessageModifier implements SyslogMessageModi
|
|||||||
int pi = message.lastIndexOf(prefix);
|
int pi = message.lastIndexOf(prefix);
|
||||||
|
|
||||||
if (pi > -1) {
|
if (pi > -1) {
|
||||||
messageAndModifier = new String[] { message.substring(0,pi), message.substring(pi+prefix.length()) };
|
messageAndModifier = new String[]{message.substring(0, pi), message.substring(pi + prefix.length())};
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int si = message.lastIndexOf(suffix);
|
int si = message.lastIndexOf(suffix);
|
||||||
|
|
||||||
if (si > -1) {
|
if (si > -1) {
|
||||||
int pi = message.lastIndexOf(prefix,si);
|
int pi = message.lastIndexOf(prefix, si);
|
||||||
|
|
||||||
if (pi > -1) {
|
if (pi > -1) {
|
||||||
messageAndModifier = new String[] { message.substring(0,pi), message.substring(pi+prefix.length(),si) };
|
messageAndModifier = new String[]{message.substring(0, pi), message.substring(pi + prefix.length(), si)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,6 +58,6 @@ public abstract class AbstractSyslogMessageModifier implements SyslogMessageModi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return verify(messageAndModifier[0],messageAndModifier[1]);
|
return verify(messageAndModifier[0], messageAndModifier[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import org.graylog2.syslog4j.SyslogConstants;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageModifierConfigIF;
|
import org.graylog2.syslog4j.SyslogMessageModifierConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogMessageModifierConfig provides a base abstract implementation of the
|
* AbstractSyslogMessageModifierConfig provides a base abstract implementation of the
|
||||||
* SyslogMessageModifierConfigIF.
|
* SyslogMessageModifierConfigIF.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogMessageModifierConfig.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: AbstractSyslogMessageModifierConfig.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogMessageModifierConfig implements SyslogMessageModifierConfigIF, SyslogCharSetIF {
|
public abstract class AbstractSyslogMessageModifierConfig implements SyslogMessageModifierConfigIF, SyslogCharSetIF {
|
||||||
private static final long serialVersionUID = 5036574188079124884L;
|
private static final long serialVersionUID = 5036574188079124884L;
|
||||||
|
|
||||||
|
@ -6,16 +6,16 @@ import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifier
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChecksumSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* ChecksumSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that provides support for Java Checksum algorithms (java.util.zip.Checksum).
|
* that provides support for Java Checksum algorithms (java.util.zip.Checksum).
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: ChecksumSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: ChecksumSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
||||||
private static final long serialVersionUID = -3268914290497005065L;
|
private static final long serialVersionUID = -3268914290497005065L;
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier
|
|||||||
|
|
||||||
return crc32;
|
return crc32;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ChecksumSyslogMessageModifier createADLER32() {
|
public static final ChecksumSyslogMessageModifier createADLER32() {
|
||||||
ChecksumSyslogMessageModifier adler32 = new ChecksumSyslogMessageModifier(ChecksumSyslogMessageModifierConfig.createADLER32());
|
ChecksumSyslogMessageModifier adler32 = new ChecksumSyslogMessageModifier(ChecksumSyslogMessageModifierConfig.createADLER32());
|
||||||
|
|
||||||
@ -60,36 +61,36 @@ public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier
|
|||||||
public boolean verify(String message, String hexChecksum) {
|
public boolean verify(String message, String hexChecksum) {
|
||||||
continuousCheckForVerify();
|
continuousCheckForVerify();
|
||||||
|
|
||||||
long checksum = Long.parseLong(hexChecksum,16);
|
long checksum = Long.parseLong(hexChecksum, 16);
|
||||||
|
|
||||||
return verify(message,checksum);
|
return verify(message, checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean verify(String message, long checksum) {
|
public boolean verify(String message, long checksum) {
|
||||||
continuousCheckForVerify();
|
continuousCheckForVerify();
|
||||||
|
|
||||||
synchronized(this.config.getChecksum()) {
|
synchronized (this.config.getChecksum()) {
|
||||||
this.config.getChecksum().reset();
|
this.config.getChecksum().reset();
|
||||||
|
|
||||||
byte[] messageBytes = SyslogUtility.getBytes(this.config,message);
|
byte[] messageBytes = SyslogUtility.getBytes(this.config, message);
|
||||||
|
|
||||||
this.config.getChecksum().update(messageBytes,0,message.length());
|
this.config.getChecksum().update(messageBytes, 0, message.length());
|
||||||
|
|
||||||
return this.config.getChecksum().getValue() == checksum;
|
return this.config.getChecksum().getValue() == checksum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String modify(SyslogIF syslog, int facility, int level, String message) {
|
public String modify(SyslogIF syslog, int facility, int level, String message) {
|
||||||
synchronized(this.config.getChecksum()) {
|
synchronized (this.config.getChecksum()) {
|
||||||
StringBuffer messageBuffer = new StringBuffer(message);
|
StringBuffer messageBuffer = new StringBuffer(message);
|
||||||
|
|
||||||
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
|
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(), message);
|
||||||
|
|
||||||
if (!this.config.isContinuous()) {
|
if (!this.config.isContinuous()) {
|
||||||
this.config.getChecksum().reset();
|
this.config.getChecksum().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config.getChecksum().update(messageBytes,0,message.length());
|
this.config.getChecksum().update(messageBytes, 0, message.length());
|
||||||
|
|
||||||
messageBuffer.append(this.config.getPrefix());
|
messageBuffer.append(this.config.getPrefix());
|
||||||
messageBuffer.append(Long.toHexString(this.config.getChecksum().getValue()).toUpperCase());
|
messageBuffer.append(Long.toHexString(this.config.getChecksum().getValue()).toUpperCase());
|
||||||
|
@ -7,16 +7,16 @@ import java.util.zip.Checksum;
|
|||||||
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
|
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChecksumSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
* ChecksumSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
||||||
* that provides configuration for ChecksumSyslogMessageModifier.
|
* that provides configuration for ChecksumSyslogMessageModifier.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: ChecksumSyslogMessageModifierConfig.java,v 1.2 2010/02/04 03:41:38 cvs Exp $
|
* @version $Id: ChecksumSyslogMessageModifierConfig.java,v 1.2 2010/02/04 03:41:38 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class ChecksumSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
public class ChecksumSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
||||||
private static final long serialVersionUID = -8298600135683882489L;
|
private static final long serialVersionUID = -8298600135683882489L;
|
||||||
|
|
||||||
|
@ -4,19 +4,19 @@ import org.graylog2.syslog4j.SyslogIF;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTMLEntityEscapeSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* HTMLEntityEscapeSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that safely escapes HTML entity characters.
|
* that safely escapes HTML entity characters.
|
||||||
*
|
* <p/>
|
||||||
* <p>This modifier is useful for applications that display log content in browsers without
|
* <p>This modifier is useful for applications that display log content in browsers without
|
||||||
* properly escaping HTML characters.</p>
|
* properly escaping HTML characters.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: HTMLEntityEscapeSyslogMessageModifier.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: HTMLEntityEscapeSyslogMessageModifier.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class HTMLEntityEscapeSyslogMessageModifier implements SyslogMessageModifierIF {
|
public class HTMLEntityEscapeSyslogMessageModifier implements SyslogMessageModifierIF {
|
||||||
private static final long serialVersionUID = -8481773209240762293L;
|
private static final long serialVersionUID = -8481773209240762293L;
|
||||||
|
|
||||||
|
@ -11,16 +11,16 @@ import org.graylog2.syslog4j.util.Base64;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* HashSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that provides support for Java Cryptographic hashes (MD5, SHA1, SHA256, etc.).
|
* that provides support for Java Cryptographic hashes (MD5, SHA1, SHA256, etc.).
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: HashSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: HashSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
||||||
private static final long serialVersionUID = 7335757344826206953L;
|
private static final long serialVersionUID = 7335757344826206953L;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
|||||||
try {
|
try {
|
||||||
MessageDigest.getInstance(config.getHashAlgorithm());
|
MessageDigest.getInstance(config.getHashAlgorithm());
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException nsae){
|
} catch (NoSuchAlgorithmException nsae) {
|
||||||
throw new SyslogRuntimeException(nsae);
|
throw new SyslogRuntimeException(nsae);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,12 +99,12 @@ public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String modify(SyslogIF syslog, int facility, int level, String message) {
|
public String modify(SyslogIF syslog, int facility, int level, String message) {
|
||||||
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
|
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(), message);
|
||||||
|
|
||||||
MessageDigest digest = obtainMessageDigest();
|
MessageDigest digest = obtainMessageDigest();
|
||||||
byte[] digestBytes = digest.digest(messageBytes);
|
byte[] digestBytes = digest.digest(messageBytes);
|
||||||
|
|
||||||
String digestString = Base64.encodeBytes(digestBytes,Base64.DONT_BREAK_LINES);
|
String digestString = Base64.encodeBytes(digestBytes, Base64.DONT_BREAK_LINES);
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer(message);
|
StringBuffer buffer = new StringBuffer(message);
|
||||||
|
|
||||||
@ -118,15 +118,15 @@ public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
|||||||
public boolean verify(String message, String base64Hash) {
|
public boolean verify(String message, String base64Hash) {
|
||||||
byte[] hash = Base64.decode(base64Hash);
|
byte[] hash = Base64.decode(base64Hash);
|
||||||
|
|
||||||
return verify(message,hash);
|
return verify(message, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean verify(String message, byte[] hash) {
|
public boolean verify(String message, byte[] hash) {
|
||||||
byte[] messageBytes = SyslogUtility.getBytes(this.config,message);
|
byte[] messageBytes = SyslogUtility.getBytes(this.config, message);
|
||||||
|
|
||||||
MessageDigest digest = obtainMessageDigest();
|
MessageDigest digest = obtainMessageDigest();
|
||||||
byte[] digestBytes = digest.digest(messageBytes);
|
byte[] digestBytes = digest.digest(messageBytes);
|
||||||
|
|
||||||
return Arrays.equals(digestBytes,hash);
|
return Arrays.equals(digestBytes, hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.message.modifier.hash;
|
|||||||
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
|
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
* HashSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
||||||
* that provides configuration for HashSyslogMessageModifier.
|
* that provides configuration for HashSyslogMessageModifier.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: HashSyslogMessageModifierConfig.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
|
* @version $Id: HashSyslogMessageModifierConfig.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class HashSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
public class HashSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
||||||
private static final long serialVersionUID = -3148300281439874231L;
|
private static final long serialVersionUID = -3148300281439874231L;
|
||||||
|
|
||||||
|
@ -14,16 +14,16 @@ import org.graylog2.syslog4j.util.Base64;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MacSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* MacSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that provides support for Java Cryptographic signed hashes (HmacSHA1, etc.)
|
* that provides support for Java Cryptographic signed hashes (HmacSHA1, etc.)
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: MacSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: MacSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
||||||
private static final long serialVersionUID = 5054979194802197540L;
|
private static final long serialVersionUID = 5054979194802197540L;
|
||||||
|
|
||||||
@ -85,14 +85,14 @@ public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String modify(SyslogIF syslog, int facility, int level, String message) {
|
public String modify(SyslogIF syslog, int facility, int level, String message) {
|
||||||
synchronized(this.mac) {
|
synchronized (this.mac) {
|
||||||
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
|
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(), message);
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer(message);
|
StringBuffer buffer = new StringBuffer(message);
|
||||||
|
|
||||||
byte[] macBytes = this.mac.doFinal(messageBytes);
|
byte[] macBytes = this.mac.doFinal(messageBytes);
|
||||||
|
|
||||||
String macString = Base64.encodeBytes(macBytes,Base64.DONT_BREAK_LINES);
|
String macString = Base64.encodeBytes(macBytes, Base64.DONT_BREAK_LINES);
|
||||||
|
|
||||||
buffer.append(this.config.getPrefix());
|
buffer.append(this.config.getPrefix());
|
||||||
buffer.append(macString);
|
buffer.append(macString);
|
||||||
@ -105,16 +105,16 @@ public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
|
|||||||
public boolean verify(String message, String base64Signature) {
|
public boolean verify(String message, String base64Signature) {
|
||||||
byte[] signature = Base64.decode(base64Signature);
|
byte[] signature = Base64.decode(base64Signature);
|
||||||
|
|
||||||
return verify(message,signature);
|
return verify(message, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean verify(String message, byte[] signature) {
|
public boolean verify(String message, byte[] signature) {
|
||||||
synchronized(this.mac) {
|
synchronized (this.mac) {
|
||||||
byte[] messageBytes = SyslogUtility.getBytes(this.config,message);
|
byte[] messageBytes = SyslogUtility.getBytes(this.config, message);
|
||||||
|
|
||||||
byte[] macBytes = this.mac.doFinal(messageBytes);
|
byte[] macBytes = this.mac.doFinal(messageBytes);
|
||||||
|
|
||||||
return Arrays.equals(macBytes,signature);
|
return Arrays.equals(macBytes, signature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,16 @@ import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifier
|
|||||||
import org.graylog2.syslog4j.util.Base64;
|
import org.graylog2.syslog4j.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MacSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
* MacSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
||||||
* that provides configuration for HashSyslogMessageModifier.
|
* that provides configuration for HashSyslogMessageModifier.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: MacSyslogMessageModifierConfig.java,v 1.3 2009/04/17 02:37:04 cvs Exp $
|
* @version $Id: MacSyslogMessageModifierConfig.java,v 1.3 2009/04/17 02:37:04 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
||||||
private static final long serialVersionUID = 4524180892377960695L;
|
private static final long serialVersionUID = 4524180892377960695L;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifie
|
|||||||
this.keyAlgorithm = keyAlgorithm;
|
this.keyAlgorithm = keyAlgorithm;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.key = new SecretKeySpec(keyBytes,keyAlgorithm);
|
this.key = new SecretKeySpec(keyBytes, keyAlgorithm);
|
||||||
|
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
throw new SyslogRuntimeException(iae);
|
throw new SyslogRuntimeException(iae);
|
||||||
@ -51,7 +51,7 @@ public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifie
|
|||||||
byte[] keyBytes = Base64.decode(base64Key);
|
byte[] keyBytes = Base64.decode(base64Key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.key = new SecretKeySpec(keyBytes,keyAlgorithm);
|
this.key = new SecretKeySpec(keyBytes, keyAlgorithm);
|
||||||
|
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
throw new SyslogRuntimeException(iae);
|
throw new SyslogRuntimeException(iae);
|
||||||
@ -59,35 +59,35 @@ public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifie
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacSHA1(Key key) {
|
public static MacSyslogMessageModifierConfig createHmacSHA1(Key key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacSHA1","SHA1",key);
|
return new MacSyslogMessageModifierConfig("HmacSHA1", "SHA1", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacSHA1(String base64Key) {
|
public static MacSyslogMessageModifierConfig createHmacSHA1(String base64Key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacSHA1","SHA1",base64Key);
|
return new MacSyslogMessageModifierConfig("HmacSHA1", "SHA1", base64Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacSHA256(Key key) {
|
public static MacSyslogMessageModifierConfig createHmacSHA256(Key key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacSHA256","SHA-256",key);
|
return new MacSyslogMessageModifierConfig("HmacSHA256", "SHA-256", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacSHA256(String base64Key) {
|
public static MacSyslogMessageModifierConfig createHmacSHA256(String base64Key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacSHA256","SHA-256",base64Key);
|
return new MacSyslogMessageModifierConfig("HmacSHA256", "SHA-256", base64Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacSHA512(Key key) {
|
public static MacSyslogMessageModifierConfig createHmacSHA512(Key key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacSHA512","SHA-512",key);
|
return new MacSyslogMessageModifierConfig("HmacSHA512", "SHA-512", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacSHA512(String base64Key) {
|
public static MacSyslogMessageModifierConfig createHmacSHA512(String base64Key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacSHA512","SHA-512",base64Key);
|
return new MacSyslogMessageModifierConfig("HmacSHA512", "SHA-512", base64Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacMD5(Key key) {
|
public static MacSyslogMessageModifierConfig createHmacMD5(Key key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacMD5","MD5",key);
|
return new MacSyslogMessageModifierConfig("HmacMD5", "MD5", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacSyslogMessageModifierConfig createHmacMD5(String base64Key) {
|
public static MacSyslogMessageModifierConfig createHmacMD5(String base64Key) {
|
||||||
return new MacSyslogMessageModifierConfig("HmacMD5","MD5",base64Key);
|
return new MacSyslogMessageModifierConfig("HmacMD5", "MD5", base64Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMacAlgorithm() {
|
public String getMacAlgorithm() {
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogIF;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SequentialSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* SequentialSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that adds an incremented number at the end.
|
* that adds an incremented number at the end.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SequentialSyslogMessageModifier.java,v 1.8 2010/11/28 04:43:31 cvs Exp $
|
* @version $Id: SequentialSyslogMessageModifier.java,v 1.8 2010/11/28 04:43:31 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF {
|
public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF {
|
||||||
private static final long serialVersionUID = 6107735010240030785L;
|
private static final long serialVersionUID = 6107735010240030785L;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
|
|||||||
public SequentialSyslogMessageModifier(SequentialSyslogMessageModifierConfig config) {
|
public SequentialSyslogMessageModifier(SequentialSyslogMessageModifierConfig config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
for(int i=0; i<(LEVEL_DEBUG + 1); i++) {
|
for (int i = 0; i < (LEVEL_DEBUG + 1); i++) {
|
||||||
this.currentSequence[i] = config.getFirstNumber();
|
this.currentSequence[i] = config.getFirstNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
|
|||||||
StringBuffer buffer = new StringBuffer(Long.toString(number));
|
StringBuffer buffer = new StringBuffer(Long.toString(number));
|
||||||
|
|
||||||
while (buffer.length() < this.config.getLastNumberDigits()) {
|
while (buffer.length() < this.config.getLastNumberDigits()) {
|
||||||
buffer.insert(0,this.config.getPadChar());
|
buffer.insert(0, this.config.getPadChar());
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
@ -47,7 +47,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
|
|||||||
|
|
||||||
public void setNextSequence(int level, long nextSequence) {
|
public void setNextSequence(int level, long nextSequence) {
|
||||||
if (nextSequence >= this.config.getFirstNumber() && nextSequence < this.config.getLastNumber()) {
|
if (nextSequence >= this.config.getFirstNumber() && nextSequence < this.config.getLastNumber()) {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
this.currentSequence[level] = nextSequence;
|
this.currentSequence[level] = nextSequence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
|
|||||||
protected String nextSequence(int level) {
|
protected String nextSequence(int level) {
|
||||||
long sequence = -1;
|
long sequence = -1;
|
||||||
|
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
sequence = this.currentSequence[level];
|
sequence = this.currentSequence[level];
|
||||||
|
|
||||||
if (this.currentSequence[level] >= this.config.getLastNumber()) {
|
if (this.currentSequence[level] >= this.config.getLastNumber()) {
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.message.modifier.sequential;
|
|||||||
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
|
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SequentialSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
* SequentialSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
|
||||||
* that provides configuration for SequentialSyslogMessageModifier.
|
* that provides configuration for SequentialSyslogMessageModifier.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SequentialSyslogMessageModifierConfig.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SequentialSyslogMessageModifierConfig.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SequentialSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
public class SequentialSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
|
||||||
private static final long serialVersionUID = 1570930406228960303L;
|
private static final long serialVersionUID = 1570930406228960303L;
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogIF;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PrefixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* PrefixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that provides support for adding static text to the beginning of a Syslog message.
|
* that provides support for adding static text to the beginning of a Syslog message.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PrefixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: PrefixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PrefixSyslogMessageModifier implements SyslogMessageModifierIF {
|
public class PrefixSyslogMessageModifier implements SyslogMessageModifierIF {
|
||||||
private static final long serialVersionUID = 6718826215583513972L;
|
private static final long serialVersionUID = 6718826215583513972L;
|
||||||
|
|
||||||
|
@ -5,17 +5,17 @@ import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StringCaseSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* StringCaseSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that provides support for shifting a Syslog message to all upper case or all
|
* that provides support for shifting a Syslog message to all upper case or all
|
||||||
* lower case.
|
* lower case.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: StringCaseSyslogMessageModifier.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: StringCaseSyslogMessageModifier.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class StringCaseSyslogMessageModifier implements SyslogMessageModifierIF {
|
public class StringCaseSyslogMessageModifier implements SyslogMessageModifierIF {
|
||||||
private static final long serialVersionUID = 8383234811585957460L;
|
private static final long serialVersionUID = 8383234811585957460L;
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogIF;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SuffixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
* SuffixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
|
||||||
* that provides support for adding static text to the end of a Syslog message.
|
* that provides support for adding static text to the end of a Syslog message.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SuffixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: SuffixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SuffixSyslogMessageModifier implements SyslogMessageModifierIF {
|
public class SuffixSyslogMessageModifier implements SyslogMessageModifierIF {
|
||||||
private static final long serialVersionUID = 7160593302741507576L;
|
private static final long serialVersionUID = 7160593302741507576L;
|
||||||
|
|
||||||
|
@ -6,23 +6,23 @@ import java.util.Map;
|
|||||||
import org.graylog2.syslog4j.impl.message.AbstractSyslogMessage;
|
import org.graylog2.syslog4j.impl.message.AbstractSyslogMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PCISyslogMessage provides support for audit trails defined by section
|
* PCISyslogMessage provides support for audit trails defined by section
|
||||||
* 10.3 of the PCI Data Security Standard (PCI DSS) versions 1.1 and 1.2.
|
* 10.3 of the PCI Data Security Standard (PCI DSS) versions 1.1 and 1.2.
|
||||||
*
|
* <p/>
|
||||||
* <p>More information on the PCI DSS specification is available here:</p>
|
* <p>More information on the PCI DSS specification is available here:</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
|
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
|
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
|
||||||
* Council LLC.</p>
|
* Council LLC.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PCISyslogMessage.java,v 1.3 2008/11/14 04:32:00 cvs Exp $
|
* @version $Id: PCISyslogMessage.java,v 1.3 2008/11/14 04:32:00 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslogMessageIF {
|
public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslogMessageIF {
|
||||||
private static final long serialVersionUID = 3571696218386879119L;
|
private static final long serialVersionUID = 3571696218386879119L;
|
||||||
|
|
||||||
@ -65,14 +65,38 @@ public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslog
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Map fields) {
|
protected void init(Map fields) {
|
||||||
if (fields.containsKey(USER_ID)) { this.userId = (String) fields.get(USER_ID); };
|
if (fields.containsKey(USER_ID)) {
|
||||||
if (fields.containsKey(EVENT_TYPE)) { this.eventType = (String) fields.get(EVENT_TYPE); };
|
this.userId = (String) fields.get(USER_ID);
|
||||||
if (fields.containsKey(DATE) && fields.get(DATE) instanceof String) { this.date = (String) fields.get(DATE); };
|
}
|
||||||
if (fields.containsKey(DATE) && fields.get(DATE) instanceof Date) { setDate((Date) fields.get(DATE)); };
|
;
|
||||||
if (fields.containsKey(TIME)) { this.time = (String) fields.get(TIME); };
|
if (fields.containsKey(EVENT_TYPE)) {
|
||||||
if (fields.containsKey(STATUS)) { this.status = (String) fields.get(STATUS); };
|
this.eventType = (String) fields.get(EVENT_TYPE);
|
||||||
if (fields.containsKey(ORIGINATION)) { this.origination = (String) fields.get(ORIGINATION); };
|
}
|
||||||
if (fields.containsKey(AFFECTED_RESOURCE)) { this.affectedResource = (String) fields.get(AFFECTED_RESOURCE); };
|
;
|
||||||
|
if (fields.containsKey(DATE) && fields.get(DATE) instanceof String) {
|
||||||
|
this.date = (String) fields.get(DATE);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (fields.containsKey(DATE) && fields.get(DATE) instanceof Date) {
|
||||||
|
setDate((Date) fields.get(DATE));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (fields.containsKey(TIME)) {
|
||||||
|
this.time = (String) fields.get(TIME);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (fields.containsKey(STATUS)) {
|
||||||
|
this.status = (String) fields.get(STATUS);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (fields.containsKey(ORIGINATION)) {
|
||||||
|
this.origination = (String) fields.get(ORIGINATION);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (fields.containsKey(AFFECTED_RESOURCE)) {
|
||||||
|
this.affectedResource = (String) fields.get(AFFECTED_RESOURCE);
|
||||||
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PCISyslogMessage(String userId, String eventType, String status, String affectedResource) {
|
public PCISyslogMessage(String userId, String eventType, String status, String affectedResource) {
|
||||||
@ -237,19 +261,19 @@ public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslog
|
|||||||
char delimiter = getDelimiter();
|
char delimiter = getDelimiter();
|
||||||
String replaceDelimiter = getReplaceDelimiter();
|
String replaceDelimiter = getReplaceDelimiter();
|
||||||
|
|
||||||
buffer.append(replaceDelimiter(USER_ID,getUserId(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(USER_ID, getUserId(), delimiter, replaceDelimiter));
|
||||||
buffer.append(delimiter);
|
buffer.append(delimiter);
|
||||||
buffer.append(replaceDelimiter(EVENT_TYPE,getEventType(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(EVENT_TYPE, getEventType(), delimiter, replaceDelimiter));
|
||||||
buffer.append(delimiter);
|
buffer.append(delimiter);
|
||||||
buffer.append(replaceDelimiter(DATE,getDate(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(DATE, getDate(), delimiter, replaceDelimiter));
|
||||||
buffer.append(delimiter);
|
buffer.append(delimiter);
|
||||||
buffer.append(replaceDelimiter(TIME,getTime(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(TIME, getTime(), delimiter, replaceDelimiter));
|
||||||
buffer.append(delimiter);
|
buffer.append(delimiter);
|
||||||
buffer.append(replaceDelimiter(STATUS,getStatus(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(STATUS, getStatus(), delimiter, replaceDelimiter));
|
||||||
buffer.append(delimiter);
|
buffer.append(delimiter);
|
||||||
buffer.append(replaceDelimiter(ORIGINATION,getOrigination(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(ORIGINATION, getOrigination(), delimiter, replaceDelimiter));
|
||||||
buffer.append(delimiter);
|
buffer.append(delimiter);
|
||||||
buffer.append(replaceDelimiter(AFFECTED_RESOURCE,getAffectedResource(),delimiter,replaceDelimiter));
|
buffer.append(replaceDelimiter(AFFECTED_RESOURCE, getAffectedResource(), delimiter, replaceDelimiter));
|
||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,36 @@
|
|||||||
package org.graylog2.syslog4j.impl.message.pci;
|
package org.graylog2.syslog4j.impl.message.pci;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PCISyslogMessageIF provides a definition of the fields for audit trails
|
* PCISyslogMessageIF provides a definition of the fields for audit trails
|
||||||
* defined by section 10.3 of the PCI Data Security Standard (PCI DSS)
|
* defined by section 10.3 of the PCI Data Security Standard (PCI DSS)
|
||||||
* versions 1.1 and 1.2.
|
* versions 1.1 and 1.2.
|
||||||
*
|
* <p/>
|
||||||
* <p>More information on the PCI DSS specification is available here:</p>
|
* <p>More information on the PCI DSS specification is available here:</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
|
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
|
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
|
||||||
* Council LLC.</p>
|
* Council LLC.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PCISyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
|
* @version $Id: PCISyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface PCISyslogMessageIF {
|
public interface PCISyslogMessageIF {
|
||||||
public String getUserId();
|
public String getUserId();
|
||||||
|
|
||||||
public String getEventType();
|
public String getEventType();
|
||||||
|
|
||||||
public String getDate();
|
public String getDate();
|
||||||
|
|
||||||
public String getTime();
|
public String getTime();
|
||||||
|
|
||||||
public String getStatus();
|
public String getStatus();
|
||||||
|
|
||||||
public String getOrigination();
|
public String getOrigination();
|
||||||
|
|
||||||
public String getAffectedResource();
|
public String getAffectedResource();
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,17 @@ import org.graylog2.syslog4j.SyslogMessageProcessorIF;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogMessageProcessor provides the ability to split a syslog message
|
* AbstractSyslogMessageProcessor provides the ability to split a syslog message
|
||||||
* into multiple messages when the message is greater than the syslog
|
* into multiple messages when the message is greater than the syslog
|
||||||
* maximum message length (1024 bytes including the header).
|
* maximum message length (1024 bytes including the header).
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogMessageProcessor.java,v 1.2 2010/11/28 04:15:18 cvs Exp $
|
* @version $Id: AbstractSyslogMessageProcessor.java,v 1.2 2010/11/28 04:15:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogMessageProcessor implements SyslogMessageProcessorIF, SyslogConstants {
|
public abstract class AbstractSyslogMessageProcessor implements SyslogMessageProcessorIF, SyslogConstants {
|
||||||
private static final long serialVersionUID = -5413127301924500938L;
|
private static final long serialVersionUID = -5413127301924500938L;
|
||||||
protected String localName = null;
|
protected String localName = null;
|
||||||
@ -29,7 +29,7 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] createPacketData(byte[] header, byte[] message, int start, int length) {
|
public byte[] createPacketData(byte[] header, byte[] message, int start, int length) {
|
||||||
return createPacketData(header,message,start,length,null,null);
|
return createPacketData(header, message, start, length, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] createPacketData(byte[] header, byte[] message, int start, int length, byte[] splitBeginText, byte[] splitEndText) {
|
public byte[] createPacketData(byte[] header, byte[] message, int start, int length, byte[] splitBeginText, byte[] splitEndText) {
|
||||||
@ -48,19 +48,19 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
|
|||||||
|
|
||||||
byte[] data = new byte[dataLength];
|
byte[] data = new byte[dataLength];
|
||||||
|
|
||||||
System.arraycopy(header,0,data,0,header.length);
|
System.arraycopy(header, 0, data, 0, header.length);
|
||||||
int pos = header.length;
|
int pos = header.length;
|
||||||
|
|
||||||
if (splitBeginText != null) {
|
if (splitBeginText != null) {
|
||||||
System.arraycopy(splitBeginText,0,data,pos,splitBeginText.length);
|
System.arraycopy(splitBeginText, 0, data, pos, splitBeginText.length);
|
||||||
pos += splitBeginText.length;
|
pos += splitBeginText.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.arraycopy(message,start,data,pos,length);
|
System.arraycopy(message, start, data, pos, length);
|
||||||
pos += length;
|
pos += length;
|
||||||
|
|
||||||
if (splitEndText != null) {
|
if (splitEndText != null) {
|
||||||
System.arraycopy(splitEndText,0,data,pos,splitEndText.length);
|
System.arraycopy(splitEndText, 0, data, pos, splitEndText.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@ -75,7 +75,7 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void appendLocalTimestamp(StringBuffer buffer) {
|
protected void appendLocalTimestamp(StringBuffer buffer) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(SYSLOG_DATEFORMAT,Locale.ENGLISH);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(SYSLOG_DATEFORMAT, Locale.ENGLISH);
|
||||||
|
|
||||||
String datePrefix = dateFormat.format(new Date());
|
String datePrefix = dateFormat.format(new Date());
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
|
|||||||
|
|
||||||
// RFC 3164 requires leading space for days 1-9
|
// RFC 3164 requires leading space for days 1-9
|
||||||
if (buffer.charAt(pos) == '0') {
|
if (buffer.charAt(pos) == '0') {
|
||||||
buffer.setCharAt(pos,' ');
|
buffer.setCharAt(pos, ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,14 +103,14 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
|
|||||||
public String createSyslogHeader(int facility, int level, String localName, boolean sendLocalTimestamp, boolean sendLocalName) {
|
public String createSyslogHeader(int facility, int level, String localName, boolean sendLocalTimestamp, boolean sendLocalName) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
appendPriority(buffer,facility,level);
|
appendPriority(buffer, facility, level);
|
||||||
|
|
||||||
if (sendLocalTimestamp) {
|
if (sendLocalTimestamp) {
|
||||||
appendLocalTimestamp(buffer);
|
appendLocalTimestamp(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendLocalName) {
|
if (sendLocalName) {
|
||||||
appendLocalName(buffer,localName);
|
appendLocalName(buffer, localName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -2,20 +2,20 @@ package org.graylog2.syslog4j.impl.message.processor;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogMessageProcessor wraps AbstractSyslogMessageProcessor.
|
* SyslogMessageProcessor wraps AbstractSyslogMessageProcessor.
|
||||||
*
|
* <p/>
|
||||||
* <p>Those wishing to replace (or improve upon) this implementation
|
* <p>Those wishing to replace (or improve upon) this implementation
|
||||||
* can write a custom SyslogMessageProcessorIF and set it per
|
* can write a custom SyslogMessageProcessorIF and set it per
|
||||||
* instance via the SyslogIF.setMessageProcessor(..) method or set it globally
|
* instance via the SyslogIF.setMessageProcessor(..) method or set it globally
|
||||||
* via the SyslogMessageProcessor.setDefault(..) method.</p>
|
* via the SyslogMessageProcessor.setDefault(..) method.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogMessageProcessor.java,v 1.7 2010/02/04 03:41:37 cvs Exp $
|
* @version $Id: SyslogMessageProcessor.java,v 1.7 2010/02/04 03:41:37 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SyslogMessageProcessor extends AbstractSyslogMessageProcessor {
|
public class SyslogMessageProcessor extends AbstractSyslogMessageProcessor {
|
||||||
private static final long serialVersionUID = -4232803978024990353L;
|
private static final long serialVersionUID = -4232803978024990353L;
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@ import org.graylog2.syslog4j.impl.message.structured.StructuredSyslogMessage;
|
|||||||
* than the syslog maximum message length (1024 bytes including the header). It
|
* than the syslog maximum message length (1024 bytes including the header). It
|
||||||
* adds support for structured syslog messages as specified by
|
* adds support for structured syslog messages as specified by
|
||||||
* draft-ietf-syslog-protocol-23. More information here:
|
* draft-ietf-syslog-protocol-23. More information here:
|
||||||
*
|
* <p/>
|
||||||
* <p>http://tools.ietf.org/html/draft-ietf-syslog-protocol-23</p>
|
* <p>http://tools.ietf.org/html/draft-ietf-syslog-protocol-23</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Those wishing to replace (or improve upon) this implementation
|
* <p>Those wishing to replace (or improve upon) this implementation
|
||||||
* can write a custom SyslogMessageProcessorIF and set it per
|
* can write a custom SyslogMessageProcessorIF and set it per
|
||||||
* instance via the SyslogIF.setStructuredMessageProcessor(..) method or set it globally
|
* instance via the SyslogIF.setStructuredMessageProcessor(..) method or set it globally
|
||||||
* via the StructuredSyslogMessageProcessor.setDefault(..) method.</p>
|
* via the StructuredSyslogMessageProcessor.setDefault(..) method.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
|
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
|
||||||
* LGPL license is available in the META-INF folder in all distributions of
|
* LGPL license is available in the META-INF folder in all distributions of
|
||||||
@ -87,14 +87,14 @@ public class StructuredSyslogMessageProcessor extends AbstractSyslogMessageProce
|
|||||||
public String createSyslogHeader(final int facility, final int level, String localName, final boolean sendLocalTimestamp, final boolean sendLocalName) {
|
public String createSyslogHeader(final int facility, final int level, String localName, final boolean sendLocalTimestamp, final boolean sendLocalName) {
|
||||||
final StringBuffer buffer = new StringBuffer();
|
final StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
appendPriority(buffer,facility,level);
|
appendPriority(buffer, facility, level);
|
||||||
buffer.append(VERSION);
|
buffer.append(VERSION);
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
|
|
||||||
getDateTimeFormatter().printTo(buffer,System.currentTimeMillis());
|
getDateTimeFormatter().printTo(buffer, System.currentTimeMillis());
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
|
|
||||||
appendLocalName(buffer,localName);
|
appendLocalName(buffer, localName);
|
||||||
|
|
||||||
buffer.append(StructuredSyslogMessage.nilProtect(this.applicationName))
|
buffer.append(StructuredSyslogMessage.nilProtect(this.applicationName))
|
||||||
.append(' ');
|
.append(' ');
|
||||||
|
@ -13,11 +13,11 @@ import org.graylog2.syslog4j.impl.message.AbstractSyslogMessage;
|
|||||||
* support for turning POJO (Plain Ol' Java Objects) into Syslog messages. It
|
* support for turning POJO (Plain Ol' Java Objects) into Syslog messages. It
|
||||||
* adds support for structured syslog messages as specified by
|
* adds support for structured syslog messages as specified by
|
||||||
* draft-ietf-syslog-protocol-23. More information here:
|
* draft-ietf-syslog-protocol-23. More information here:
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
||||||
* </p>
|
* </p>
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
|
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
|
||||||
* LGPL license is available in the META-INF folder in all distributions of
|
* LGPL license is available in the META-INF folder in all distributions of
|
||||||
@ -43,11 +43,11 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
/**
|
/**
|
||||||
* Constructs the {@link StructuredSyslogMessage} using MSGID,
|
* Constructs the {@link StructuredSyslogMessage} using MSGID,
|
||||||
* STRUCTURED-DATA and MSG fields, as described in:
|
* STRUCTURED-DATA and MSG fields, as described in:
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
||||||
* </p>
|
* </p>
|
||||||
*
|
* <p/>
|
||||||
* The Map must be a String -> (Map of String -> String), which encompasses
|
* The Map must be a String -> (Map of String -> String), which encompasses
|
||||||
* the STRUCTURED-DATA field described in above document.
|
* the STRUCTURED-DATA field described in above document.
|
||||||
*
|
*
|
||||||
@ -68,7 +68,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
private void ensureCorrectMapType() {
|
private void ensureCorrectMapType() {
|
||||||
if (!(getStructuredData() == null)) {
|
if (!(getStructuredData() == null)) {
|
||||||
Set sdEntrySet = getStructuredData().entrySet();
|
Set sdEntrySet = getStructuredData().entrySet();
|
||||||
for (Iterator it = sdEntrySet.iterator(); it.hasNext();) {
|
for (Iterator it = sdEntrySet.iterator(); it.hasNext(); ) {
|
||||||
Map.Entry sdEntry = (Map.Entry) it.next();
|
Map.Entry sdEntry = (Map.Entry) it.next();
|
||||||
if (!(sdEntry.getKey() instanceof String)) {
|
if (!(sdEntry.getKey() instanceof String)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@ -80,7 +80,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set entrySet = ((Map) sdEntry.getValue()).entrySet();
|
Set entrySet = ((Map) sdEntry.getValue()).entrySet();
|
||||||
for (Iterator it2 = entrySet.iterator(); it2.hasNext();) {
|
for (Iterator it2 = entrySet.iterator(); it2.hasNext(); ) {
|
||||||
Map.Entry entry = (Map.Entry) it2.next();
|
Map.Entry entry = (Map.Entry) it2.next();
|
||||||
|
|
||||||
if (!(entry.getKey() instanceof String)) {
|
if (!(entry.getKey() instanceof String)) {
|
||||||
@ -194,7 +194,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
/**
|
/**
|
||||||
* Returns the MSGID field of the structured message format, as described
|
* Returns the MSGID field of the structured message format, as described
|
||||||
* in:
|
* in:
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
||||||
* </p>
|
* </p>
|
||||||
@ -208,7 +208,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
/**
|
/**
|
||||||
* Returns the structured data map. The Map is a String -> (Map of String ->
|
* Returns the structured data map. The Map is a String -> (Map of String ->
|
||||||
* String), which encompasses the STRUCTURED-DATA field, as described in:
|
* String), which encompasses the STRUCTURED-DATA field, as described in:
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
||||||
* </p>
|
* </p>
|
||||||
@ -221,7 +221,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the MSG field of the structured message format, as described in:
|
* Returns the MSG field of the structured message format, as described in:
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
||||||
* </p>
|
* </p>
|
||||||
@ -260,7 +260,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
sb.append(SyslogConstants.STRUCTURED_DATA_EMPTY_VALUE);
|
sb.append(SyslogConstants.STRUCTURED_DATA_EMPTY_VALUE);
|
||||||
} else {
|
} else {
|
||||||
Set sdEntrySet = getStructuredData().entrySet();
|
Set sdEntrySet = getStructuredData().entrySet();
|
||||||
for (Iterator it = sdEntrySet.iterator(); it.hasNext();) {
|
for (Iterator it = sdEntrySet.iterator(); it.hasNext(); ) {
|
||||||
final Map.Entry sdElement = (Map.Entry) it.next();
|
final Map.Entry sdElement = (Map.Entry) it.next();
|
||||||
final String sdId = (String) sdElement.getKey();
|
final String sdId = (String) sdElement.getKey();
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
|
|||||||
|
|
||||||
if (sdParams != null) {
|
if (sdParams != null) {
|
||||||
Set entrySet = sdParams.entrySet();
|
Set entrySet = sdParams.entrySet();
|
||||||
for (Iterator it2 = entrySet.iterator(); it2.hasNext();) {
|
for (Iterator it2 = entrySet.iterator(); it2.hasNext(); ) {
|
||||||
Map.Entry entry = (Map.Entry) it2.next();
|
Map.Entry entry = (Map.Entry) it2.next();
|
||||||
final String paramName = (String) entry.getKey();
|
final String paramName = (String) entry.getKey();
|
||||||
final String paramValue = (String) entry.getValue();
|
final String paramValue = (String) entry.getValue();
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.message.structured;
|
|||||||
import org.graylog2.syslog4j.SyslogMessageIF;
|
import org.graylog2.syslog4j.SyslogMessageIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StructuredSyslogMessageIF is a "marker" interface to identify structured
|
* StructuredSyslogMessageIF is a "marker" interface to identify structured
|
||||||
* SyslogMessageIF implementations.
|
* SyslogMessageIF implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: StructuredSyslogMessageIF.java,v 1.1 2009/07/22 15:54:23 cvs Exp $
|
* @version $Id: StructuredSyslogMessageIF.java,v 1.1 2009/07/22 15:54:23 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface StructuredSyslogMessageIF extends SyslogMessageIF {
|
public interface StructuredSyslogMessageIF extends SyslogMessageIF {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogMessageProcessorIF;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MultipleSyslog is an aggregator Syslog implementation for allowing a single
|
* MultipleSyslog is an aggregator Syslog implementation for allowing a single
|
||||||
* Syslog call to send to multiple Syslog implementations.
|
* Syslog call to send to multiple Syslog implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: MultipleSyslog.java,v 1.10 2010/02/11 05:00:55 cvs Exp $
|
* @version $Id: MultipleSyslog.java,v 1.10 2010/02/11 05:00:55 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class MultipleSyslog implements SyslogIF {
|
public class MultipleSyslog implements SyslogIF {
|
||||||
private static final long serialVersionUID = 587308197526365108L;
|
private static final long serialVersionUID = 587308197526365108L;
|
||||||
|
|
||||||
@ -41,91 +41,91 @@ public class MultipleSyslog implements SyslogIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
log(SyslogConstants.LEVEL_DEBUG,message);
|
log(SyslogConstants.LEVEL_DEBUG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(SyslogMessageIF message) {
|
public void debug(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_DEBUG,message);
|
log(SyslogConstants.LEVEL_DEBUG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void critical(String message) {
|
public void critical(String message) {
|
||||||
log(SyslogConstants.LEVEL_CRITICAL,message);
|
log(SyslogConstants.LEVEL_CRITICAL, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void critical(SyslogMessageIF message) {
|
public void critical(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_CRITICAL,message);
|
log(SyslogConstants.LEVEL_CRITICAL, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(String message) {
|
public void error(String message) {
|
||||||
log(SyslogConstants.LEVEL_ERROR,message);
|
log(SyslogConstants.LEVEL_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(SyslogMessageIF message) {
|
public void error(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_ERROR,message);
|
log(SyslogConstants.LEVEL_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alert(String message) {
|
public void alert(String message) {
|
||||||
log(SyslogConstants.LEVEL_ALERT,message);
|
log(SyslogConstants.LEVEL_ALERT, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alert(SyslogMessageIF message) {
|
public void alert(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_ALERT,message);
|
log(SyslogConstants.LEVEL_ALERT, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notice(String message) {
|
public void notice(String message) {
|
||||||
log(SyslogConstants.LEVEL_NOTICE,message);
|
log(SyslogConstants.LEVEL_NOTICE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notice(SyslogMessageIF message) {
|
public void notice(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_NOTICE,message);
|
log(SyslogConstants.LEVEL_NOTICE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void emergency(String message) {
|
public void emergency(String message) {
|
||||||
log(SyslogConstants.LEVEL_EMERGENCY,message);
|
log(SyslogConstants.LEVEL_EMERGENCY, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void emergency(SyslogMessageIF message) {
|
public void emergency(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_EMERGENCY,message);
|
log(SyslogConstants.LEVEL_EMERGENCY, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String message) {
|
public void info(String message) {
|
||||||
log(SyslogConstants.LEVEL_INFO,message);
|
log(SyslogConstants.LEVEL_INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(SyslogMessageIF message) {
|
public void info(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_INFO,message);
|
log(SyslogConstants.LEVEL_INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(String message) {
|
public void warn(String message) {
|
||||||
log(SyslogConstants.LEVEL_WARN,message);
|
log(SyslogConstants.LEVEL_WARN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(SyslogMessageIF message) {
|
public void warn(SyslogMessageIF message) {
|
||||||
log(SyslogConstants.LEVEL_WARN,message);
|
log(SyslogConstants.LEVEL_WARN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(int level, String message) {
|
public void log(int level, String message) {
|
||||||
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
|
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
|
||||||
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
||||||
|
|
||||||
SyslogIF syslog = Syslog.getInstance(protocol);
|
SyslogIF syslog = Syslog.getInstance(protocol);
|
||||||
|
|
||||||
syslog.log(level,message);
|
syslog.log(level, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(int level, SyslogMessageIF message) {
|
public void log(int level, SyslogMessageIF message) {
|
||||||
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
|
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
|
||||||
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
||||||
|
|
||||||
SyslogIF syslog = Syslog.getInstance(protocol);
|
SyslogIF syslog = Syslog.getInstance(protocol);
|
||||||
|
|
||||||
syslog.log(level,message);
|
syslog.log(level, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() throws SyslogRuntimeException {
|
public void flush() throws SyslogRuntimeException {
|
||||||
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
|
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
|
||||||
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
||||||
|
|
||||||
SyslogIF syslog = Syslog.getInstance(protocol);
|
SyslogIF syslog = Syslog.getInstance(protocol);
|
||||||
@ -135,7 +135,7 @@ public class MultipleSyslog implements SyslogIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() throws SyslogRuntimeException {
|
public void shutdown() throws SyslogRuntimeException {
|
||||||
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
|
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
|
||||||
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
|
||||||
|
|
||||||
SyslogIF syslog = Syslog.getInstance(protocol);
|
SyslogIF syslog = Syslog.getInstance(protocol);
|
||||||
|
@ -10,16 +10,16 @@ import org.graylog2.syslog4j.SyslogMessageModifierIF;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MultipleSyslogConfig is a configuration Object for allowing a single
|
* MultipleSyslogConfig is a configuration Object for allowing a single
|
||||||
* Syslog call to send to multiple Syslog implementations.
|
* Syslog call to send to multiple Syslog implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: MultipleSyslogConfig.java,v 1.8 2010/11/28 04:15:18 cvs Exp $
|
* @version $Id: MultipleSyslogConfig.java,v 1.8 2010/11/28 04:15:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class MultipleSyslogConfig implements SyslogConfigIF {
|
public class MultipleSyslogConfig implements SyslogConfigIF {
|
||||||
private static final long serialVersionUID = 753704522364959612L;
|
private static final long serialVersionUID = 753704522364959612L;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class MultipleSyslogConfig implements SyslogConfigIF {
|
|||||||
if (protocols != null) {
|
if (protocols != null) {
|
||||||
this.syslogProtocols = new ArrayList(protocols.length);
|
this.syslogProtocols = new ArrayList(protocols.length);
|
||||||
|
|
||||||
for(int i=0; i<protocols.length; i++) {
|
for (int i = 0; i < protocols.length; i++) {
|
||||||
this.syslogProtocols.add(protocols[i]);
|
this.syslogProtocols.add(protocols[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public class MultipleSyslogConfig implements SyslogConfigIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void insertProtocol(int index, String protocol) {
|
public void insertProtocol(int index, String protocol) {
|
||||||
this.syslogProtocols.add(index,protocol);
|
this.syslogProtocols.add(index, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeProtocol(String protocol) {
|
public void removeProtocol(String protocol) {
|
||||||
|
@ -7,16 +7,16 @@ import org.graylog2.syslog4j.impl.AbstractSyslog;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractNetSyslog is an abstract extension of AbstractSyslog
|
* AbstractNetSyslog is an abstract extension of AbstractSyslog
|
||||||
* that provides support for network-based syslog clients.
|
* that provides support for network-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractNetSyslog.java,v 1.7 2009/01/24 22:00:18 cvs Exp $
|
* @version $Id: AbstractNetSyslog.java,v 1.7 2009/01/24 22:00:18 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractNetSyslog extends AbstractSyslog {
|
public abstract class AbstractNetSyslog extends AbstractSyslog {
|
||||||
private static final long serialVersionUID = -3250858945515853967L;
|
private static final long serialVersionUID = -3250858945515853967L;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public abstract class AbstractNetSyslog extends AbstractSyslog {
|
|||||||
|
|
||||||
if (this.netSyslogConfig.isCacheHostAddress()) {
|
if (this.netSyslogConfig.isCacheHostAddress()) {
|
||||||
if (this.cachedHostAddress == null) {
|
if (this.cachedHostAddress == null) {
|
||||||
synchronized(cachedHostAddressSyncObject) {
|
synchronized (cachedHostAddressSyncObject) {
|
||||||
if (this.cachedHostAddress == null) {
|
if (this.cachedHostAddress == null) {
|
||||||
this.cachedHostAddress = SyslogUtility.getInetAddress(this.syslogConfig.getHost());
|
this.cachedHostAddress = SyslogUtility.getInetAddress(this.syslogConfig.getHost());
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.net;
|
|||||||
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
|
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractNetSyslogConfig is an abstract extension of AbstractSyslogConfig
|
* AbstractNetSyslogConfig is an abstract extension of AbstractSyslogConfig
|
||||||
* that provides configuration support for network-based syslog clients.
|
* that provides configuration support for network-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractNetSyslogConfig.java,v 1.12 2010/10/25 03:50:25 cvs Exp $
|
* @version $Id: AbstractNetSyslogConfig.java,v 1.12 2010/10/25 03:50:25 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractNetSyslogConfig extends AbstractSyslogConfig implements AbstractNetSyslogConfigIF {
|
public abstract class AbstractNetSyslogConfig extends AbstractSyslogConfig implements AbstractNetSyslogConfigIF {
|
||||||
private static final long serialVersionUID = 7240133962159244924L;
|
private static final long serialVersionUID = 7240133962159244924L;
|
||||||
|
|
||||||
|
@ -3,17 +3,18 @@ package org.graylog2.syslog4j.impl.net;
|
|||||||
import org.graylog2.syslog4j.impl.AbstractSyslogConfigIF;
|
import org.graylog2.syslog4j.impl.AbstractSyslogConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractNetSyslogConfigIF is a configuration interface supporting network-based
|
* AbstractNetSyslogConfigIF is a configuration interface supporting network-based
|
||||||
* Syslog implementations.
|
* Syslog implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractNetSyslogConfigIF.java,v 1.4 2009/06/06 19:11:02 cvs Exp $
|
* @version $Id: AbstractNetSyslogConfigIF.java,v 1.4 2009/06/06 19:11:02 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface AbstractNetSyslogConfigIF extends AbstractSyslogConfigIF {
|
public interface AbstractNetSyslogConfigIF extends AbstractSyslogConfigIF {
|
||||||
public boolean isCacheHostAddress();
|
public boolean isCacheHostAddress();
|
||||||
|
|
||||||
public void setCacheHostAddress(boolean cacheHostAddress);
|
public void setCacheHostAddress(boolean cacheHostAddress);
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
|
|||||||
import org.graylog2.syslog4j.impl.net.AbstractNetSyslog;
|
import org.graylog2.syslog4j.impl.net.AbstractNetSyslog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslog is an extension of AbstractSyslog that provides support for
|
* TCPNetSyslog is an extension of AbstractSyslog that provides support for
|
||||||
* TCP/IP-based syslog clients.
|
* TCP/IP-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslog.java,v 1.21 2010/11/28 04:43:31 cvs Exp $
|
* @version $Id: TCPNetSyslog.java,v 1.21 2010/11/28 04:43:31 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class TCPNetSyslog extends AbstractNetSyslog {
|
public class TCPNetSyslog extends AbstractNetSyslog {
|
||||||
private static final long serialVersionUID = -2157528355215068721L;
|
private static final long serialVersionUID = -2157528355215068721L;
|
||||||
|
|
||||||
@ -56,10 +56,10 @@ public class TCPNetSyslog extends AbstractNetSyslog {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (syslogWriter.hasThread()) {
|
if (syslogWriter.hasThread()) {
|
||||||
syslogWriter.queue(level,message);
|
syslogWriter.queue(level, message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
synchronized(syslogWriter) {
|
synchronized (syslogWriter) {
|
||||||
syslogWriter.write(message);
|
syslogWriter.write(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfig;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
* TCPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
||||||
* configuration support for TCP/IP-based syslog clients.
|
* configuration support for TCP/IP-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslogConfig.java,v 1.18 2010/10/29 03:14:12 cvs Exp $
|
* @version $Id: TCPNetSyslogConfig.java,v 1.18 2010/10/29 03:14:12 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNetSyslogConfigIF {
|
public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNetSyslogConfigIF {
|
||||||
private static final long serialVersionUID = 9023152050686365460L;
|
private static final long serialVersionUID = 9023152050686365460L;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDelimiterSequence(String delimiterSequence) {
|
public void setDelimiterSequence(String delimiterSequence) {
|
||||||
this.delimiterSequence = SyslogUtility.getBytes(this,delimiterSequence);
|
this.delimiterSequence = SyslogUtility.getBytes(this, delimiterSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPersistentConnection() {
|
public boolean isPersistentConnection() {
|
||||||
|
@ -3,38 +3,46 @@ package org.graylog2.syslog4j.impl.net.tcp;
|
|||||||
import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfigIF;
|
import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
|
* TCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
|
||||||
* Syslog implementations.
|
* Syslog implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslogConfigIF.java,v 1.6 2010/10/29 03:14:12 cvs Exp $
|
* @version $Id: TCPNetSyslogConfigIF.java,v 1.6 2010/10/29 03:14:12 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface TCPNetSyslogConfigIF extends AbstractNetSyslogConfigIF {
|
public interface TCPNetSyslogConfigIF extends AbstractNetSyslogConfigIF {
|
||||||
public byte[] getDelimiterSequence();
|
public byte[] getDelimiterSequence();
|
||||||
|
|
||||||
public void setDelimiterSequence(byte[] delimiterSequence);
|
public void setDelimiterSequence(byte[] delimiterSequence);
|
||||||
|
|
||||||
public boolean isPersistentConnection();
|
public boolean isPersistentConnection();
|
||||||
|
|
||||||
public void setPersistentConnection(boolean persistentConnection);
|
public void setPersistentConnection(boolean persistentConnection);
|
||||||
|
|
||||||
public boolean isSoLinger();
|
public boolean isSoLinger();
|
||||||
|
|
||||||
public void setSoLinger(boolean soLinger);
|
public void setSoLinger(boolean soLinger);
|
||||||
|
|
||||||
public int getSoLingerSeconds();
|
public int getSoLingerSeconds();
|
||||||
|
|
||||||
public void setSoLingerSeconds(int soLingerSeconds);
|
public void setSoLingerSeconds(int soLingerSeconds);
|
||||||
|
|
||||||
public boolean isKeepAlive();
|
public boolean isKeepAlive();
|
||||||
|
|
||||||
public void setKeepAlive(boolean keepAlive);
|
public void setKeepAlive(boolean keepAlive);
|
||||||
|
|
||||||
public boolean isReuseAddress();
|
public boolean isReuseAddress();
|
||||||
|
|
||||||
public void setReuseAddress(boolean reuseAddress);
|
public void setReuseAddress(boolean reuseAddress);
|
||||||
|
|
||||||
public boolean isSetBufferSize();
|
public boolean isSetBufferSize();
|
||||||
|
|
||||||
public void setSetBufferSize(boolean setBufferSize);
|
public void setSetBufferSize(boolean setBufferSize);
|
||||||
|
|
||||||
public int getFreshConnectionInterval();
|
public int getFreshConnectionInterval();
|
||||||
|
|
||||||
public void setFreshConnectionInterval(int interval);
|
public void setFreshConnectionInterval(int interval);
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,19 @@ import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslogWriter is an implementation of Runnable that supports sending
|
* TCPNetSyslogWriter is an implementation of Runnable that supports sending
|
||||||
* TCP-based messages within a separate Thread.
|
* TCP-based messages within a separate Thread.
|
||||||
*
|
* <p/>
|
||||||
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
|
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
|
||||||
* a queuing mechanism is used (via LinkedList).</p>
|
* a queuing mechanism is used (via LinkedList).</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslogWriter.java,v 1.20 2010/11/28 01:38:08 cvs Exp $
|
* @version $Id: TCPNetSyslogWriter.java,v 1.20 2010/11/28 01:38:08 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
||||||
private static final long serialVersionUID = -6388813866108482855L;
|
private static final long serialVersionUID = -6388813866108482855L;
|
||||||
|
|
||||||
@ -57,10 +57,10 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
|||||||
protected Socket createSocket(InetAddress hostAddress, int port, boolean keepalive) throws IOException {
|
protected Socket createSocket(InetAddress hostAddress, int port, boolean keepalive) throws IOException {
|
||||||
SocketFactory socketFactory = obtainSocketFactory();
|
SocketFactory socketFactory = obtainSocketFactory();
|
||||||
|
|
||||||
Socket newSocket = socketFactory.createSocket(hostAddress,port);
|
Socket newSocket = socketFactory.createSocket(hostAddress, port);
|
||||||
|
|
||||||
if (this.tcpNetSyslogConfig.isSoLinger()) {
|
if (this.tcpNetSyslogConfig.isSoLinger()) {
|
||||||
newSocket.setSoLinger(true,this.tcpNetSyslogConfig.getSoLingerSeconds());
|
newSocket.setSoLinger(true, this.tcpNetSyslogConfig.getSoLingerSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tcpNetSyslogConfig.isKeepAlive()) {
|
if (this.tcpNetSyslogConfig.isKeepAlive()) {
|
||||||
@ -96,7 +96,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
|||||||
try {
|
try {
|
||||||
InetAddress hostAddress = this.tcpNetSyslog.getHostAddress();
|
InetAddress hostAddress = this.tcpNetSyslog.getHostAddress();
|
||||||
|
|
||||||
this.socket = createSocket(hostAddress,this.syslog.getConfig().getPort(),this.tcpNetSyslogConfig.isPersistentConnection());
|
this.socket = createSocket(hostAddress, this.syslog.getConfig().getPort(), this.tcpNetSyslogConfig.isPersistentConnection());
|
||||||
lastSocketCreationTimeMs = System.currentTimeMillis();
|
lastSocketCreationTimeMs = System.currentTimeMillis();
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
@ -131,7 +131,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
|||||||
Socket currentSocket = null;
|
Socket currentSocket = null;
|
||||||
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while(attempts != -1 && attempts < (this.tcpNetSyslogConfig.getWriteRetries() + 1)) {
|
while (attempts != -1 && attempts < (this.tcpNetSyslogConfig.getWriteRetries() + 1)) {
|
||||||
try {
|
try {
|
||||||
currentSocket = getSocket();
|
currentSocket = getSocket();
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
|||||||
long timeStart = System.currentTimeMillis();
|
long timeStart = System.currentTimeMillis();
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
|
||||||
while(!done) {
|
while (!done) {
|
||||||
if (this.socket == null || this.socket.isClosed()) {
|
if (this.socket == null || this.socket.isClosed()) {
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
|
@ -7,16 +7,16 @@ import org.graylog2.syslog4j.impl.pool.AbstractSyslogPoolFactory;
|
|||||||
import org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory;
|
import org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PooledTCPNetSyslog is an extension of TCPNetSyslog which provides support
|
* PooledTCPNetSyslog is an extension of TCPNetSyslog which provides support
|
||||||
* for Apache Commons Pool.
|
* for Apache Commons Pool.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PooledTCPNetSyslog.java,v 1.5 2008/12/10 04:30:15 cvs Exp $
|
* @version $Id: PooledTCPNetSyslog.java,v 1.5 2008/12/10 04:30:15 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PooledTCPNetSyslog extends TCPNetSyslog {
|
public class PooledTCPNetSyslog extends TCPNetSyslog {
|
||||||
private static final long serialVersionUID = 4279960451141784200L;
|
private static final long serialVersionUID = 4279960451141784200L;
|
||||||
|
|
||||||
|
@ -5,16 +5,16 @@ import org.graylog2.syslog4j.SyslogPoolConfigIF;
|
|||||||
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig;
|
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NetSyslogPoolFactory is an implementation of SyslogPoolConfigIF
|
* NetSyslogPoolFactory is an implementation of SyslogPoolConfigIF
|
||||||
* which provides configuration support for the Apache Commons Pool.
|
* which provides configuration support for the Apache Commons Pool.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PooledTCPNetSyslogConfig.java,v 1.3 2008/11/26 15:01:47 cvs Exp $
|
* @version $Id: PooledTCPNetSyslogConfig.java,v 1.3 2008/11/26 15:01:47 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PooledTCPNetSyslogConfig extends TCPNetSyslogConfig implements SyslogPoolConfigIF {
|
public class PooledTCPNetSyslogConfig extends TCPNetSyslogConfig implements SyslogPoolConfigIF {
|
||||||
private static final long serialVersionUID = 2283355983363422888L;
|
private static final long serialVersionUID = 2283355983363422888L;
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslog;
|
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslog is an extension of AbstractSyslog that provides support for
|
* SSLTCPNetSyslog is an extension of AbstractSyslog that provides support for
|
||||||
* TCP/IP-based (over SSL/TLS) syslog clients.
|
* TCP/IP-based (over SSL/TLS) syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslog.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslog.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SSLTCPNetSyslog extends TCPNetSyslog {
|
public class SSLTCPNetSyslog extends TCPNetSyslog {
|
||||||
private static final long serialVersionUID = 2766654802524487317L;
|
private static final long serialVersionUID = 2766654802524487317L;
|
||||||
|
|
||||||
@ -25,25 +25,25 @@ public class SSLTCPNetSyslog extends TCPNetSyslog {
|
|||||||
String keyStore = sslTcpNetSyslogConfig.getKeyStore();
|
String keyStore = sslTcpNetSyslogConfig.getKeyStore();
|
||||||
|
|
||||||
if (keyStore != null && !"".equals(keyStore.trim())) {
|
if (keyStore != null && !"".equals(keyStore.trim())) {
|
||||||
System.setProperty("javax.net.ssl.keyStore",keyStore);
|
System.setProperty("javax.net.ssl.keyStore", keyStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
String keyStorePassword = sslTcpNetSyslogConfig.getKeyStorePassword();
|
String keyStorePassword = sslTcpNetSyslogConfig.getKeyStorePassword();
|
||||||
|
|
||||||
if (keyStorePassword != null && !"".equals(keyStorePassword.trim())) {
|
if (keyStorePassword != null && !"".equals(keyStorePassword.trim())) {
|
||||||
System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
|
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
String trustStore = sslTcpNetSyslogConfig.getTrustStore();
|
String trustStore = sslTcpNetSyslogConfig.getTrustStore();
|
||||||
|
|
||||||
if (trustStore != null && !"".equals(trustStore.trim())) {
|
if (trustStore != null && !"".equals(trustStore.trim())) {
|
||||||
System.setProperty("javax.net.ssl.trustStore",trustStore);
|
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
String trustStorePassword = sslTcpNetSyslogConfig.getTrustStorePassword();
|
String trustStorePassword = sslTcpNetSyslogConfig.getTrustStorePassword();
|
||||||
|
|
||||||
if (trustStorePassword != null && !"".equals(trustStorePassword.trim())) {
|
if (trustStorePassword != null && !"".equals(trustStorePassword.trim())) {
|
||||||
System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
|
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.net.tcp.ssl;
|
|||||||
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig;
|
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslogConfig is an extension of TCPNetSyslogConfig that provides
|
* SSLTCPNetSyslogConfig is an extension of TCPNetSyslogConfig that provides
|
||||||
* configuration support for TCP/IP-based (over SSL/TLS) syslog clients.
|
* configuration support for TCP/IP-based (over SSL/TLS) syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SSLTCPNetSyslogConfig extends TCPNetSyslogConfig implements SSLTCPNetSyslogConfigIF {
|
public class SSLTCPNetSyslogConfig extends TCPNetSyslogConfig implements SSLTCPNetSyslogConfigIF {
|
||||||
private static final long serialVersionUID = 5569086213824510834L;
|
private static final long serialVersionUID = 5569086213824510834L;
|
||||||
|
|
||||||
|
@ -3,26 +3,30 @@ package org.graylog2.syslog4j.impl.net.tcp.ssl;
|
|||||||
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfigIF;
|
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
|
* SSLTCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
|
||||||
* (over SSL/TLS) Syslog implementations.
|
* (over SSL/TLS) Syslog implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslogConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslogConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SSLTCPNetSyslogConfigIF extends TCPNetSyslogConfigIF {
|
public interface SSLTCPNetSyslogConfigIF extends TCPNetSyslogConfigIF {
|
||||||
public String getKeyStore();
|
public String getKeyStore();
|
||||||
|
|
||||||
public void setKeyStore(String keyStore);
|
public void setKeyStore(String keyStore);
|
||||||
|
|
||||||
public String getKeyStorePassword();
|
public String getKeyStorePassword();
|
||||||
|
|
||||||
public void setKeyStorePassword(String keyStorePassword);
|
public void setKeyStorePassword(String keyStorePassword);
|
||||||
|
|
||||||
public String getTrustStore();
|
public String getTrustStore();
|
||||||
|
|
||||||
public void setTrustStore(String trustStore);
|
public void setTrustStore(String trustStore);
|
||||||
|
|
||||||
public String getTrustStorePassword();
|
public String getTrustStorePassword();
|
||||||
|
|
||||||
public void setTrustStorePassword(String trustStorePassword);
|
public void setTrustStorePassword(String trustStorePassword);
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,19 @@ import javax.net.ssl.SSLSocketFactory;
|
|||||||
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogWriter;
|
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslogWriter is an implementation of Runnable that supports sending
|
* SSLTCPNetSyslogWriter is an implementation of Runnable that supports sending
|
||||||
* TCP/IP-based (over SSL/TLS) messages within a separate Thread.
|
* TCP/IP-based (over SSL/TLS) messages within a separate Thread.
|
||||||
*
|
* <p/>
|
||||||
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
|
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
|
||||||
* a queuing mechanism is used (via LinkedList).</p>
|
* a queuing mechanism is used (via LinkedList).</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslogWriter.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslogWriter.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SSLTCPNetSyslogWriter extends TCPNetSyslogWriter {
|
public class SSLTCPNetSyslogWriter extends TCPNetSyslogWriter {
|
||||||
private static final long serialVersionUID = 8944446235285662244L;
|
private static final long serialVersionUID = 8944446235285662244L;
|
||||||
|
|
||||||
|
@ -6,16 +6,16 @@ import org.graylog2.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogConfigIF;
|
|||||||
import org.graylog2.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogWriter;
|
import org.graylog2.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PooledSSLTCPNetSyslogConfig is an extension of PooledTCPNetSyslogConfig
|
* PooledSSLTCPNetSyslogConfig is an extension of PooledTCPNetSyslogConfig
|
||||||
* which provides configuration support for the Apache Commons Pool.
|
* which provides configuration support for the Apache Commons Pool.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PooledSSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: PooledSSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PooledSSLTCPNetSyslogConfig extends PooledTCPNetSyslogConfig implements SSLTCPNetSyslogConfigIF {
|
public class PooledSSLTCPNetSyslogConfig extends PooledTCPNetSyslogConfig implements SSLTCPNetSyslogConfigIF {
|
||||||
private static final long serialVersionUID = 2092268298395023976L;
|
private static final long serialVersionUID = 2092268298395023976L;
|
||||||
|
|
||||||
|
@ -11,16 +11,16 @@ import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
|
|||||||
import org.graylog2.syslog4j.impl.net.AbstractNetSyslog;
|
import org.graylog2.syslog4j.impl.net.AbstractNetSyslog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UDPNetSyslog is an extension of AbstractSyslog that provides support for
|
* UDPNetSyslog is an extension of AbstractSyslog that provides support for
|
||||||
* UDP/IP-based syslog clients.
|
* UDP/IP-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UDPNetSyslog.java,v 1.18 2010/10/27 06:18:10 cvs Exp $
|
* @version $Id: UDPNetSyslog.java,v 1.18 2010/10/27 06:18:10 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UDPNetSyslog extends AbstractNetSyslog {
|
public class UDPNetSyslog extends AbstractNetSyslog {
|
||||||
private static final long serialVersionUID = 5259485504549037999L;
|
private static final long serialVersionUID = 5259485504549037999L;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class UDPNetSyslog extends AbstractNetSyslog {
|
|||||||
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
|
|
||||||
while(attempts != -1 && attempts < (this.netSyslogConfig.getWriteRetries() + 1)) {
|
while (attempts != -1 && attempts < (this.netSyslogConfig.getWriteRetries() + 1)) {
|
||||||
try {
|
try {
|
||||||
this.socket.send(packet);
|
this.socket.send(packet);
|
||||||
attempts = -1;
|
attempts = -1;
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.net.udp;
|
|||||||
import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfig;
|
import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UDPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
* UDPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
||||||
* configuration support for UDP/IP-based syslog clients.
|
* configuration support for UDP/IP-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UDPNetSyslogConfig.java,v 1.6 2008/11/14 04:32:00 cvs Exp $
|
* @version $Id: UDPNetSyslogConfig.java,v 1.6 2008/11/14 04:32:00 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
|
public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
|
||||||
private static final long serialVersionUID = 4465067182562754345L;
|
private static final long serialVersionUID = 4465067182562754345L;
|
||||||
|
|
||||||
@ -21,11 +21,11 @@ public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UDPNetSyslogConfig(int facility, String host, int port) {
|
public UDPNetSyslogConfig(int facility, String host, int port) {
|
||||||
super(facility,host,port);
|
super(facility, host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UDPNetSyslogConfig(int facility, String host) {
|
public UDPNetSyslogConfig(int facility, String host) {
|
||||||
super(facility,host);
|
super(facility, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UDPNetSyslogConfig(int facility) {
|
public UDPNetSyslogConfig(int facility) {
|
||||||
@ -33,7 +33,7 @@ public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UDPNetSyslogConfig(String host, int port) {
|
public UDPNetSyslogConfig(String host, int port) {
|
||||||
super(host,port);
|
super(host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UDPNetSyslogConfig(String host) {
|
public UDPNetSyslogConfig(String host) {
|
||||||
|
@ -8,17 +8,17 @@ import org.graylog2.syslog4j.impl.AbstractSyslogConfigIF;
|
|||||||
import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
|
import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogPoolFactory is an abstract implementation of the Apache Commons Pool
|
* AbstractSyslogPoolFactory is an abstract implementation of the Apache Commons Pool
|
||||||
* BasePoolableObjectFactory.
|
* BasePoolableObjectFactory.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:11 cvs Exp $
|
* @version $Id: AbstractSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:11 cvs Exp $
|
||||||
* @see org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory
|
* @see org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogPoolFactory extends BasePoolableObjectFactory {
|
public abstract class AbstractSyslogPoolFactory extends BasePoolableObjectFactory {
|
||||||
private static final long serialVersionUID = -7441569603980981508L;
|
private static final long serialVersionUID = -7441569603980981508L;
|
||||||
|
|
||||||
|
@ -7,16 +7,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.impl.pool.AbstractSyslogPoolFactory;
|
import org.graylog2.syslog4j.impl.pool.AbstractSyslogPoolFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GenericSyslogPoolFactory is an implementation of the Apache Commons Pool
|
* GenericSyslogPoolFactory is an implementation of the Apache Commons Pool
|
||||||
* BasePoolableObjectFactory using a GenericObjectPool.
|
* BasePoolableObjectFactory using a GenericObjectPool.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: GenericSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:10 cvs Exp $
|
* @version $Id: GenericSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:10 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class GenericSyslogPoolFactory extends AbstractSyslogPoolFactory {
|
public class GenericSyslogPoolFactory extends AbstractSyslogPoolFactory {
|
||||||
protected void configureGenericObjectPool(GenericObjectPool genericObjectPool) throws SyslogRuntimeException {
|
protected void configureGenericObjectPool(GenericObjectPool genericObjectPool) throws SyslogRuntimeException {
|
||||||
SyslogPoolConfigIF poolConfig = null;
|
SyslogPoolConfigIF poolConfig = null;
|
||||||
|
@ -11,19 +11,19 @@ import com.sun.jna.Memory;
|
|||||||
import com.sun.jna.Native;
|
import com.sun.jna.Native;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UnixSyslog is an extension of AbstractSyslog that provides support for
|
* UnixSyslog is an extension of AbstractSyslog that provides support for
|
||||||
* Unix-based syslog clients.
|
* Unix-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>This class requires the JNA (Java Native Access) library to directly
|
* <p>This class requires the JNA (Java Native Access) library to directly
|
||||||
* access the native C libraries utilized on Unix platforms.</p>
|
* access the native C libraries utilized on Unix platforms.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UnixSyslog.java,v 1.27 2010/10/25 04:21:19 cvs Exp $
|
* @version $Id: UnixSyslog.java,v 1.27 2010/10/25 04:21:19 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UnixSyslog extends AbstractSyslog {
|
public class UnixSyslog extends AbstractSyslog {
|
||||||
private static final long serialVersionUID = 4973353204252276740L;
|
private static final long serialVersionUID = 4973353204252276740L;
|
||||||
|
|
||||||
@ -31,7 +31,9 @@ public class UnixSyslog extends AbstractSyslog {
|
|||||||
|
|
||||||
protected interface CLibrary extends Library {
|
protected interface CLibrary extends Library {
|
||||||
public void openlog(final Memory ident, int option, int facility);
|
public void openlog(final Memory ident, int option, int facility);
|
||||||
|
|
||||||
public void syslog(int priority, final String format, final String message);
|
public void syslog(int priority, final String format, final String message);
|
||||||
|
|
||||||
public void closelog();
|
public void closelog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ public class UnixSyslog extends AbstractSyslog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (libraryInstance == null) {
|
if (libraryInstance == null) {
|
||||||
libraryInstance = (CLibrary) Native.loadLibrary(config.getLibrary(),CLibrary.class);
|
libraryInstance = (CLibrary) Native.loadLibrary(config.getLibrary(), CLibrary.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ public class UnixSyslog extends AbstractSyslog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void write(int level, String message, UnixSyslogConfig config) throws SyslogRuntimeException {
|
protected static void write(int level, String message, UnixSyslogConfig config) throws SyslogRuntimeException {
|
||||||
synchronized(libraryInstance) {
|
synchronized (libraryInstance) {
|
||||||
if (currentFacility != config.getFacility()) {
|
if (currentFacility != config.getFacility()) {
|
||||||
if (openlogCalled) {
|
if (openlogCalled) {
|
||||||
libraryInstance.closelog();
|
libraryInstance.closelog();
|
||||||
@ -86,13 +88,13 @@ public class UnixSyslog extends AbstractSyslog {
|
|||||||
identBuffer.setString(0, ident, false);
|
identBuffer.setString(0, ident, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryInstance.openlog(identBuffer,config.getOption(),currentFacility);
|
libraryInstance.openlog(identBuffer, config.getOption(), currentFacility);
|
||||||
openlogCalled = true;
|
openlogCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int priority = currentFacility | level;
|
int priority = currentFacility | level;
|
||||||
|
|
||||||
libraryInstance.syslog(priority,"%s",message);
|
libraryInstance.syslog(priority, "%s", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,11 +103,11 @@ public class UnixSyslog extends AbstractSyslog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void log(SyslogMessageProcessorIF messageProcessor, int level, String message) {
|
public void log(SyslogMessageProcessorIF messageProcessor, int level, String message) {
|
||||||
write(level,message,this.unixSyslogConfig);
|
write(level, message, this.unixSyslogConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() throws SyslogRuntimeException {
|
public void flush() throws SyslogRuntimeException {
|
||||||
synchronized(libraryInstance) {
|
synchronized (libraryInstance) {
|
||||||
libraryInstance.closelog();
|
libraryInstance.closelog();
|
||||||
openlogCalled = false;
|
openlogCalled = false;
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
|
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UnixSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
* UnixSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
||||||
* configuration support for Unix-based syslog clients.
|
* configuration support for Unix-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UnixSyslogConfig.java,v 1.13 2010/10/25 03:50:25 cvs Exp $
|
* @version $Id: UnixSyslogConfig.java,v 1.13 2010/10/25 03:50:25 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UnixSyslogConfig extends AbstractSyslogConfig {
|
public class UnixSyslogConfig extends AbstractSyslogConfig {
|
||||||
private static final long serialVersionUID = -4805767812011660656L;
|
private static final long serialVersionUID = -4805767812011660656L;
|
||||||
|
|
||||||
|
@ -12,40 +12,44 @@ import com.sun.jna.Native;
|
|||||||
import com.sun.jna.Structure;
|
import com.sun.jna.Structure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UnixSocketSyslog is an extension of AbstractSyslog that provides support for
|
* UnixSocketSyslog is an extension of AbstractSyslog that provides support for
|
||||||
* Unix socket-based syslog clients.
|
* Unix socket-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>This class requires the JNA (Java Native Access) library to directly
|
* <p>This class requires the JNA (Java Native Access) library to directly
|
||||||
* access the native C libraries utilized on Unix platforms.</p>
|
* access the native C libraries utilized on Unix platforms.</p>
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UnixSocketSyslog.java,v 1.13 2010/11/16 00:52:01 cvs Exp $
|
* @version $Id: UnixSocketSyslog.java,v 1.13 2010/11/16 00:52:01 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UnixSocketSyslog extends AbstractSyslog {
|
public class UnixSocketSyslog extends AbstractSyslog {
|
||||||
private static final long serialVersionUID = 39878807911936785L;
|
private static final long serialVersionUID = 39878807911936785L;
|
||||||
|
|
||||||
protected static class SockAddr extends Structure {
|
protected static class SockAddr extends Structure {
|
||||||
public final static int SUN_PATH_SIZE = 108;
|
public final static int SUN_PATH_SIZE = 108;
|
||||||
public final static byte[] ZERO_BYTE = new byte[] { 0 };
|
public final static byte[] ZERO_BYTE = new byte[]{0};
|
||||||
|
|
||||||
public short sun_family = 1;
|
public short sun_family = 1;
|
||||||
public byte[] sun_path = new byte[SUN_PATH_SIZE];
|
public byte[] sun_path = new byte[SUN_PATH_SIZE];
|
||||||
|
|
||||||
public void setSunPath(String sunPath) {
|
public void setSunPath(String sunPath) {
|
||||||
System.arraycopy(sunPath.getBytes(), 0,this.sun_path, 0, sunPath.length());
|
System.arraycopy(sunPath.getBytes(), 0, this.sun_path, 0, sunPath.length());
|
||||||
System.arraycopy(ZERO_BYTE,0,this.sun_path,sunPath.length(),1);
|
System.arraycopy(ZERO_BYTE, 0, this.sun_path, sunPath.length(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected interface CLibrary extends Library {
|
protected interface CLibrary extends Library {
|
||||||
public int socket(int domain, int type, int protocol);
|
public int socket(int domain, int type, int protocol);
|
||||||
|
|
||||||
public int connect(int sockfd, SockAddr sockaddr, int addrlen);
|
public int connect(int sockfd, SockAddr sockaddr, int addrlen);
|
||||||
|
|
||||||
public int write(int fd, ByteBuffer buffer, int count);
|
public int write(int fd, ByteBuffer buffer, int count);
|
||||||
|
|
||||||
public int close(int fd);
|
public int close(int fd);
|
||||||
|
|
||||||
public String strerror(int errno);
|
public String strerror(int errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ public class UnixSocketSyslog extends AbstractSyslog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.libraryLoaded) {
|
if (!this.libraryLoaded) {
|
||||||
this.libraryInstance = (CLibrary) Native.loadLibrary(this.unixSocketSyslogConfig.getLibrary(),CLibrary.class);
|
this.libraryInstance = (CLibrary) Native.loadLibrary(this.unixSocketSyslogConfig.getLibrary(), CLibrary.class);
|
||||||
this.libraryLoaded = true;
|
this.libraryLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +87,7 @@ public class UnixSocketSyslog extends AbstractSyslog {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(),this.unixSocketSyslogConfig.getType(),this.unixSocketSyslogConfig.getProtocol());
|
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(), this.unixSocketSyslogConfig.getType(), this.unixSocketSyslogConfig.getProtocol());
|
||||||
|
|
||||||
if (this.fd == -1) {
|
if (this.fd == -1) {
|
||||||
this.fd = -1;
|
this.fd = -1;
|
||||||
@ -114,13 +118,13 @@ public class UnixSocketSyslog extends AbstractSyslog {
|
|||||||
|
|
||||||
ByteBuffer byteBuffer = ByteBuffer.wrap(message);
|
ByteBuffer byteBuffer = ByteBuffer.wrap(message);
|
||||||
|
|
||||||
this.libraryInstance.write(this.fd,byteBuffer,message.length);
|
this.libraryInstance.write(this.fd, byteBuffer, message.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() throws SyslogRuntimeException {
|
public void flush() throws SyslogRuntimeException {
|
||||||
shutdown();
|
shutdown();
|
||||||
|
|
||||||
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(),this.unixSocketSyslogConfig.getType(),this.unixSocketSyslogConfig.getProtocol());
|
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(), this.unixSocketSyslogConfig.getType(), this.unixSocketSyslogConfig.getProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() throws SyslogRuntimeException {
|
public void shutdown() throws SyslogRuntimeException {
|
||||||
|
@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
|
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UnixSocketSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
* UnixSocketSyslogConfig is an extension of AbstractNetSyslogConfig that provides
|
||||||
* configuration support for Unix socket-based syslog clients.
|
* configuration support for Unix socket-based syslog clients.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UnixSocketSyslogConfig.java,v 1.8 2010/11/12 03:43:12 cvs Exp $
|
* @version $Id: UnixSocketSyslogConfig.java,v 1.8 2010/11/12 03:43:12 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UnixSocketSyslogConfig extends AbstractSyslogConfig {
|
public class UnixSocketSyslogConfig extends AbstractSyslogConfig {
|
||||||
private static final long serialVersionUID = -3145794243736015707L;
|
private static final long serialVersionUID = -3145794243736015707L;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import org.graylog2.syslog4j.util.SyslogUtility;
|
|||||||
/**
|
/**
|
||||||
* This class provides a Singleton-based interface for Syslog4j
|
* This class provides a Singleton-based interface for Syslog4j
|
||||||
* server implementations.
|
* server implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
@ -128,7 +128,7 @@ public class SyslogServer implements SyslogConstants {
|
|||||||
|
|
||||||
SyslogServerIF syslogServer = null;
|
SyslogServerIF syslogServer = null;
|
||||||
|
|
||||||
synchronized(instances) {
|
synchronized (instances) {
|
||||||
if (instances.containsKey(syslogProtocol)) {
|
if (instances.containsKey(syslogProtocol)) {
|
||||||
throwRuntimeException("SyslogServer instance \"" + syslogProtocol + "\" already defined.");
|
throwRuntimeException("SyslogServer instance \"" + syslogProtocol + "\" already defined.");
|
||||||
return null;
|
return null;
|
||||||
@ -149,16 +149,16 @@ public class SyslogServer implements SyslogConstants {
|
|||||||
throw new SyslogRuntimeException(ie);
|
throw new SyslogRuntimeException(ie);
|
||||||
}
|
}
|
||||||
|
|
||||||
syslogServer.initialize(syslogProtocol,config);
|
syslogServer.initialize(syslogProtocol, config);
|
||||||
|
|
||||||
instances.put(syslogProtocol,syslogServer);
|
instances.put(syslogProtocol, syslogServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return syslogServer;
|
return syslogServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final SyslogServerIF createThreadedInstance(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException {
|
public static final SyslogServerIF createThreadedInstance(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException {
|
||||||
createInstance(protocol,config);
|
createInstance(protocol, config);
|
||||||
|
|
||||||
SyslogServerIF server = getThreadedInstance(protocol);
|
SyslogServerIF server = getThreadedInstance(protocol);
|
||||||
|
|
||||||
@ -213,8 +213,8 @@ public class SyslogServer implements SyslogConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static void initialize() {
|
public synchronized static void initialize() {
|
||||||
createInstance(UDP,new UDPNetSyslogServerConfig());
|
createInstance(UDP, new UDPNetSyslogServerConfig());
|
||||||
createInstance(TCP,new TCPNetSyslogServerConfig());
|
createInstance(TCP, new TCPNetSyslogServerConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static final void shutdown() throws SyslogRuntimeException {
|
public synchronized static final void shutdown() throws SyslogRuntimeException {
|
||||||
@ -222,7 +222,7 @@ public class SyslogServer implements SyslogConstants {
|
|||||||
|
|
||||||
Iterator i = protocols.iterator();
|
Iterator i = protocols.iterator();
|
||||||
|
|
||||||
while(i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
String protocol = (String) i.next();
|
String protocol = (String) i.next();
|
||||||
|
|
||||||
SyslogServerIF syslogServer = (SyslogServerIF) instances.get(protocol);
|
SyslogServerIF syslogServer = (SyslogServerIF) instances.get(protocol);
|
||||||
|
@ -7,44 +7,54 @@ import org.graylog2.syslog4j.SyslogConstants;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogServerConfigIF provides a common, extensible configuration interface for all
|
* SyslogServerConfigIF provides a common, extensible configuration interface for all
|
||||||
* implementations of SyslogServerIF.
|
* implementations of SyslogServerIF.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogServerConfigIF.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
|
* @version $Id: SyslogServerConfigIF.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogServerConfigIF extends SyslogConstants, SyslogCharSetIF {
|
public interface SyslogServerConfigIF extends SyslogConstants, SyslogCharSetIF {
|
||||||
public Class getSyslogServerClass();
|
public Class getSyslogServerClass();
|
||||||
|
|
||||||
public String getHost();
|
public String getHost();
|
||||||
|
|
||||||
public void setHost(String host) throws SyslogRuntimeException;
|
public void setHost(String host) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public int getPort();
|
public int getPort();
|
||||||
|
|
||||||
public void setPort(int port) throws SyslogRuntimeException;
|
public void setPort(int port) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public boolean isUseDaemonThread();
|
public boolean isUseDaemonThread();
|
||||||
|
|
||||||
public void setUseDaemonThread(boolean useDaemonThread);
|
public void setUseDaemonThread(boolean useDaemonThread);
|
||||||
|
|
||||||
public int getThreadPriority();
|
public int getThreadPriority();
|
||||||
|
|
||||||
public void setThreadPriority(int threadPriority);
|
public void setThreadPriority(int threadPriority);
|
||||||
|
|
||||||
public List getEventHandlers();
|
public List getEventHandlers();
|
||||||
|
|
||||||
public long getShutdownWait();
|
public long getShutdownWait();
|
||||||
|
|
||||||
public void setShutdownWait(long shutdownWait);
|
public void setShutdownWait(long shutdownWait);
|
||||||
|
|
||||||
public void addEventHandler(SyslogServerEventHandlerIF eventHandler);
|
public void addEventHandler(SyslogServerEventHandlerIF eventHandler);
|
||||||
|
|
||||||
public void insertEventHandler(int pos, SyslogServerEventHandlerIF eventHandler);
|
public void insertEventHandler(int pos, SyslogServerEventHandlerIF eventHandler);
|
||||||
|
|
||||||
public void removeEventHandler(SyslogServerEventHandlerIF eventHandler);
|
public void removeEventHandler(SyslogServerEventHandlerIF eventHandler);
|
||||||
|
|
||||||
public void removeAllEventHandlers();
|
public void removeAllEventHandlers();
|
||||||
|
|
||||||
public boolean isUseStructuredData();
|
public boolean isUseStructuredData();
|
||||||
|
|
||||||
public void setUseStructuredData(boolean useStructuredData);
|
public void setUseStructuredData(boolean useStructuredData);
|
||||||
|
|
||||||
public Object getDateTimeFormatter();
|
public Object getDateTimeFormatter();
|
||||||
|
|
||||||
public void setDateTimeFormatter(Object dateTimeFormatter);
|
public void setDateTimeFormatter(Object dateTimeFormatter);
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,6 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
public abstract interface SyslogServerEventHandlerIF extends Serializable {
|
public abstract interface SyslogServerEventHandlerIF extends Serializable {
|
||||||
public void initialize(SyslogServerIF syslogServer);
|
public void initialize(SyslogServerIF syslogServer);
|
||||||
|
|
||||||
public void destroy(SyslogServerIF syslogServer);
|
public void destroy(SyslogServerIF syslogServer);
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import java.util.Date;
|
|||||||
import org.graylog2.syslog4j.SyslogCharSetIF;
|
import org.graylog2.syslog4j.SyslogCharSetIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogServerEventIF provides an extensible interface for Syslog4j
|
* SyslogServerEventIF provides an extensible interface for Syslog4j
|
||||||
* server events.
|
* server events.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogServerEventIF.java,v 1.4 2010/11/28 01:38:08 cvs Exp $
|
* @version $Id: SyslogServerEventIF.java,v 1.4 2010/11/28 01:38:08 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogServerEventIF extends SyslogCharSetIF {
|
public interface SyslogServerEventIF extends SyslogCharSetIF {
|
||||||
/**
|
/**
|
||||||
* Note: getRaw() may use System.arraycopy(..) each time it is called; best to call it once and store the result.
|
* Note: getRaw() may use System.arraycopy(..) each time it is called; best to call it once and store the result.
|
||||||
@ -24,18 +24,24 @@ public interface SyslogServerEventIF extends SyslogCharSetIF {
|
|||||||
public byte[] getRaw();
|
public byte[] getRaw();
|
||||||
|
|
||||||
public int getFacility();
|
public int getFacility();
|
||||||
|
|
||||||
public void setFacility(int facility);
|
public void setFacility(int facility);
|
||||||
|
|
||||||
public Date getDate();
|
public Date getDate();
|
||||||
|
|
||||||
public void setDate(Date date);
|
public void setDate(Date date);
|
||||||
|
|
||||||
public int getLevel();
|
public int getLevel();
|
||||||
|
|
||||||
public void setLevel(int level);
|
public void setLevel(int level);
|
||||||
|
|
||||||
public String getHost();
|
public String getHost();
|
||||||
|
|
||||||
public void setHost(String host);
|
public void setHost(String host);
|
||||||
|
|
||||||
public boolean isHostStrippedFromMessage();
|
public boolean isHostStrippedFromMessage();
|
||||||
|
|
||||||
public String getMessage();
|
public String getMessage();
|
||||||
|
|
||||||
public void setMessage(String message);
|
public void setMessage(String message);
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,26 @@ package org.graylog2.syslog4j.server;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogServerIF provides a common interface for all Syslog4j server implementations.
|
* SyslogServerIF provides a common interface for all Syslog4j server implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogServerIF.java,v 1.5 2008/11/07 15:15:41 cvs Exp $
|
* @version $Id: SyslogServerIF.java,v 1.5 2008/11/07 15:15:41 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogServerIF extends Runnable {
|
public interface SyslogServerIF extends Runnable {
|
||||||
public void initialize(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException;
|
public void initialize(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException;
|
||||||
|
|
||||||
public String getProtocol();
|
public String getProtocol();
|
||||||
|
|
||||||
public SyslogServerConfigIF getConfig();
|
public SyslogServerConfigIF getConfig();
|
||||||
|
|
||||||
public void run();
|
public void run();
|
||||||
|
|
||||||
public Thread getThread();
|
public Thread getThread();
|
||||||
|
|
||||||
public void setThread(Thread thread);
|
public void setThread(Thread thread);
|
||||||
|
|
||||||
public void shutdown();
|
public void shutdown();
|
||||||
|
@ -8,7 +8,7 @@ import org.graylog2.syslog4j.util.SyslogUtility;
|
|||||||
/**
|
/**
|
||||||
* This class provides a command-line interface for Syslog4j
|
* This class provides a command-line interface for Syslog4j
|
||||||
* server implementations.
|
* server implementations.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
@ -57,17 +57,51 @@ public class SyslogServerMain {
|
|||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(i < args.length) {
|
while (i < args.length) {
|
||||||
String arg = args[i++];
|
String arg = args[i++];
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
|
|
||||||
if ("-h".equals(arg)) { if (i == args.length) { options.usage = "Must specify host with -h"; return options; } match = true; options.host = args[i++]; }
|
if ("-h".equals(arg)) {
|
||||||
if ("-p".equals(arg)) { if (i == args.length) { options.usage = "Must specify port with -p"; return options; } match = true; options.port = args[i++]; }
|
if (i == args.length) {
|
||||||
if ("-t".equals(arg)) { if (i == args.length) { options.usage = "Must specify value (in milliseconds)"; return options; } match = true; options.timeout = args[i++]; }
|
options.usage = "Must specify host with -h";
|
||||||
if ("-o".equals(arg)) { if (i == args.length) { options.usage = "Must specify file with -o"; return options; } match = true; options.fileName = args[i++]; }
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.host = args[i++];
|
||||||
|
}
|
||||||
|
if ("-p".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify port with -p";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.port = args[i++];
|
||||||
|
}
|
||||||
|
if ("-t".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify value (in milliseconds)";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.timeout = args[i++];
|
||||||
|
}
|
||||||
|
if ("-o".equals(arg)) {
|
||||||
|
if (i == args.length) {
|
||||||
|
options.usage = "Must specify file with -o";
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
match = true;
|
||||||
|
options.fileName = args[i++];
|
||||||
|
}
|
||||||
|
|
||||||
if ("-a".equals(arg)) { match = true; options.append = true; }
|
if ("-a".equals(arg)) {
|
||||||
if ("-q".equals(arg)) { match = true; options.quiet = true; }
|
match = true;
|
||||||
|
options.append = true;
|
||||||
|
}
|
||||||
|
if ("-q".equals(arg)) {
|
||||||
|
match = true;
|
||||||
|
options.quiet = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
if (options.protocol != null) {
|
if (options.protocol != null) {
|
||||||
@ -97,7 +131,11 @@ public class SyslogServerMain {
|
|||||||
|
|
||||||
if (options.usage != null) {
|
if (options.usage != null) {
|
||||||
usage(options.usage);
|
usage(options.usage);
|
||||||
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
|
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
|
||||||
|
System.exit(1);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.quiet) {
|
if (!options.quiet) {
|
||||||
@ -106,7 +144,11 @@ public class SyslogServerMain {
|
|||||||
|
|
||||||
if (!SyslogServer.exists(options.protocol)) {
|
if (!SyslogServer.exists(options.protocol)) {
|
||||||
usage("Protocol \"" + options.protocol + "\" not supported");
|
usage("Protocol \"" + options.protocol + "\" not supported");
|
||||||
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
|
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
|
||||||
|
System.exit(1);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SyslogServerIF syslogServer = SyslogServer.getInstance(options.protocol);
|
SyslogServerIF syslogServer = SyslogServer.getInstance(options.protocol);
|
||||||
@ -140,7 +182,7 @@ public class SyslogServerMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.fileName != null) {
|
if (options.fileName != null) {
|
||||||
SyslogServerEventHandlerIF eventHandler = new FileSyslogServerEventHandler(options.fileName,options.append);
|
SyslogServerEventHandlerIF eventHandler = new FileSyslogServerEventHandler(options.fileName, options.append);
|
||||||
syslogServerConfig.addEventHandler(eventHandler);
|
syslogServerConfig.addEventHandler(eventHandler);
|
||||||
if (!options.quiet) {
|
if (!options.quiet) {
|
||||||
System.out.println((options.append ? "Appending" : "Writing") + " to file: " + options.fileName);
|
System.out.println((options.append ? "Appending" : "Writing") + " to file: " + options.fileName);
|
||||||
@ -158,7 +200,7 @@ public class SyslogServerMain {
|
|||||||
|
|
||||||
SyslogServer.getThreadedInstance(options.protocol);
|
SyslogServer.getThreadedInstance(options.protocol);
|
||||||
|
|
||||||
while(true) {
|
while (true) {
|
||||||
SyslogUtility.sleep(1000);
|
SyslogUtility.sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,10 @@ import java.net.SocketAddress;
|
|||||||
|
|
||||||
public interface SyslogServerSessionEventHandlerIF extends SyslogServerEventHandlerIF {
|
public interface SyslogServerSessionEventHandlerIF extends SyslogServerEventHandlerIF {
|
||||||
public Object sessionOpened(SyslogServerIF syslogServer, SocketAddress socketAddress);
|
public Object sessionOpened(SyslogServerIF syslogServer, SocketAddress socketAddress);
|
||||||
|
|
||||||
public void event(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event);
|
public void event(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event);
|
||||||
|
|
||||||
public void exception(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception);
|
public void exception(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception);
|
||||||
|
|
||||||
public void sessionClosed(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, boolean timeout);
|
public void sessionClosed(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, boolean timeout);
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,18 @@ import java.net.SocketAddress;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogServerEventHandlerIF provides an extensible interface for Syslog4j
|
* SyslogServerEventHandlerIF provides an extensible interface for Syslog4j
|
||||||
* server event handlers.
|
* server event handlers.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogServerSessionlessEventHandlerIF.java,v 1.1 2010/11/12 02:56:44 cvs Exp $
|
* @version $Id: SyslogServerSessionlessEventHandlerIF.java,v 1.1 2010/11/12 02:56:44 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SyslogServerSessionlessEventHandlerIF extends SyslogServerEventHandlerIF {
|
public interface SyslogServerSessionlessEventHandlerIF extends SyslogServerEventHandlerIF {
|
||||||
public void event(SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event);
|
public void event(SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event);
|
||||||
|
|
||||||
public void exception(SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception);
|
public void exception(SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception);
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,15 @@ import org.graylog2.syslog4j.server.impl.event.structured.StructuredSyslogServer
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogServer provides a base abstract implementation of the SyslogServerIF.
|
* AbstractSyslogServer provides a base abstract implementation of the SyslogServerIF.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogServer.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
|
* @version $Id: AbstractSyslogServer.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogServer implements SyslogServerIF {
|
public abstract class AbstractSyslogServer implements SyslogServerIF {
|
||||||
public static class Sessions extends HashMap {
|
public static class Sessions extends HashMap {
|
||||||
private static final long serialVersionUID = -4438949276263772580L;
|
private static final long serialVersionUID = -4438949276263772580L;
|
||||||
@ -38,8 +38,8 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
public static final Object syncObject = new Object();
|
public static final Object syncObject = new Object();
|
||||||
|
|
||||||
public void addSocket(Socket socket) {
|
public void addSocket(Socket socket) {
|
||||||
synchronized(syncObject) {
|
synchronized (syncObject) {
|
||||||
put(socket,new HashMap());
|
put(socket, new HashMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,19 +53,19 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addSession(Socket socket, SyslogServerEventHandlerIF eventHandler, Object session) {
|
public void addSession(Socket socket, SyslogServerEventHandlerIF eventHandler, Object session) {
|
||||||
synchronized(syncObject) {
|
synchronized (syncObject) {
|
||||||
Map handlerMap = getHandlerMap(socket);
|
Map handlerMap = getHandlerMap(socket);
|
||||||
|
|
||||||
if (handlerMap == null) {
|
if (handlerMap == null) {
|
||||||
handlerMap = new HashMap();
|
handlerMap = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
handlerMap.put(eventHandler,session);
|
handlerMap.put(eventHandler, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSocket(Socket socket) {
|
public void removeSocket(Socket socket) {
|
||||||
synchronized(syncObject) {
|
synchronized (syncObject) {
|
||||||
Map handlerMap = getHandlerMap(socket);
|
Map handlerMap = getHandlerMap(socket);
|
||||||
|
|
||||||
if (handlerMap != null) {
|
if (handlerMap != null) {
|
||||||
@ -85,7 +85,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object getSession(Socket socket, SyslogServerEventHandlerIF eventHandler) {
|
public Object getSession(Socket socket, SyslogServerEventHandlerIF eventHandler) {
|
||||||
synchronized(syncObject) {
|
synchronized (syncObject) {
|
||||||
Map handlerMap = getHandlerMap(socket);
|
Map handlerMap = getHandlerMap(socket);
|
||||||
|
|
||||||
Object session = handlerMap.get(eventHandler);
|
Object session = handlerMap.get(eventHandler);
|
||||||
@ -139,7 +139,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
protected static boolean isStructuredMessage(SyslogCharSetIF syslogCharSet, byte[] receiveData) {
|
protected static boolean isStructuredMessage(SyslogCharSetIF syslogCharSet, byte[] receiveData) {
|
||||||
String receiveDataString = SyslogUtility.newString(syslogCharSet, receiveData);
|
String receiveDataString = SyslogUtility.newString(syslogCharSet, receiveData);
|
||||||
|
|
||||||
boolean isStructuredMessage = isStructuredMessage(syslogCharSet,receiveDataString);
|
boolean isStructuredMessage = isStructuredMessage(syslogCharSet, receiveDataString);
|
||||||
|
|
||||||
return isStructuredMessage;
|
return isStructuredMessage;
|
||||||
}
|
}
|
||||||
@ -160,15 +160,15 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
protected static SyslogServerEventIF createEvent(SyslogServerConfigIF serverConfig, byte[] lineBytes, int lineBytesLength, InetAddress inetAddr) {
|
protected static SyslogServerEventIF createEvent(SyslogServerConfigIF serverConfig, byte[] lineBytes, int lineBytesLength, InetAddress inetAddr) {
|
||||||
SyslogServerEventIF event = null;
|
SyslogServerEventIF event = null;
|
||||||
|
|
||||||
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig,lineBytes)) {
|
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig, lineBytes)) {
|
||||||
event = new StructuredSyslogServerEvent(lineBytes,lineBytesLength,inetAddr);
|
event = new StructuredSyslogServerEvent(lineBytes, lineBytesLength, inetAddr);
|
||||||
|
|
||||||
if (serverConfig.getDateTimeFormatter() != null) {
|
if (serverConfig.getDateTimeFormatter() != null) {
|
||||||
((StructuredSyslogServerEvent) event).setDateTimeFormatter(serverConfig.getDateTimeFormatter());
|
((StructuredSyslogServerEvent) event).setDateTimeFormatter(serverConfig.getDateTimeFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
event = new SyslogServerEvent(lineBytes,lineBytesLength,inetAddr);
|
event = new SyslogServerEvent(lineBytes, lineBytesLength, inetAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
@ -177,11 +177,11 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
protected static SyslogServerEventIF createEvent(SyslogServerConfigIF serverConfig, String line, InetAddress inetAddr) {
|
protected static SyslogServerEventIF createEvent(SyslogServerConfigIF serverConfig, String line, InetAddress inetAddr) {
|
||||||
SyslogServerEventIF event = null;
|
SyslogServerEventIF event = null;
|
||||||
|
|
||||||
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig,line)) {
|
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig, line)) {
|
||||||
event = new StructuredSyslogServerEvent(line,inetAddr);
|
event = new StructuredSyslogServerEvent(line, inetAddr);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
event = new SyslogServerEvent(line,inetAddr);
|
event = new SyslogServerEvent(line, inetAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
@ -190,7 +190,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
public static void handleInitialize(SyslogServerIF syslogServer) {
|
public static void handleInitialize(SyslogServerIF syslogServer) {
|
||||||
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
||||||
|
|
||||||
for(int i=0; i<eventHandlers.size(); i++) {
|
for (int i = 0; i < eventHandlers.size(); i++) {
|
||||||
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -205,7 +205,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
public static void handleDestroy(SyslogServerIF syslogServer) {
|
public static void handleDestroy(SyslogServerIF syslogServer) {
|
||||||
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
||||||
|
|
||||||
for(int i=0; i<eventHandlers.size(); i++) {
|
for (int i = 0; i < eventHandlers.size(); i++) {
|
||||||
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -220,20 +220,20 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
public static void handleSessionOpen(Sessions sessions, SyslogServerIF syslogServer, Socket socket) {
|
public static void handleSessionOpen(Sessions sessions, SyslogServerIF syslogServer, Socket socket) {
|
||||||
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
||||||
|
|
||||||
for(int i=0; i<eventHandlers.size(); i++) {
|
for (int i = 0; i < eventHandlers.size(); i++) {
|
||||||
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
||||||
|
|
||||||
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
||||||
try {
|
try {
|
||||||
Object session = ((SyslogServerSessionEventHandlerIF) eventHandler).sessionOpened(syslogServer,socket.getRemoteSocketAddress());
|
Object session = ((SyslogServerSessionEventHandlerIF) eventHandler).sessionOpened(syslogServer, socket.getRemoteSocketAddress());
|
||||||
|
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
sessions.addSession(socket,eventHandler,session);
|
sessions.addSession(socket, eventHandler, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionEventHandlerIF) eventHandler).exception(null,syslogServer,socket.getRemoteSocketAddress(),exception);
|
((SyslogServerSessionEventHandlerIF) eventHandler).exception(null, syslogServer, socket.getRemoteSocketAddress(), exception);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
@ -246,18 +246,18 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
public static void handleSessionClosed(Sessions sessions, SyslogServerIF syslogServer, Socket socket, boolean timeout) {
|
public static void handleSessionClosed(Sessions sessions, SyslogServerIF syslogServer, Socket socket, boolean timeout) {
|
||||||
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
||||||
|
|
||||||
for(int i=0; i<eventHandlers.size(); i++) {
|
for (int i = 0; i < eventHandlers.size(); i++) {
|
||||||
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
||||||
|
|
||||||
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
||||||
Object session = sessions.getSession(socket,eventHandler);
|
Object session = sessions.getSession(socket, eventHandler);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionEventHandlerIF) eventHandler).sessionClosed(session,syslogServer,socket.getRemoteSocketAddress(),timeout);
|
((SyslogServerSessionEventHandlerIF) eventHandler).sessionClosed(session, syslogServer, socket.getRemoteSocketAddress(), timeout);
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session,syslogServer,socket.getRemoteSocketAddress(),exception);
|
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session, syslogServer, socket.getRemoteSocketAddress(), exception);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
@ -268,28 +268,28 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, DatagramPacket packet, SyslogServerEventIF event) {
|
public static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, DatagramPacket packet, SyslogServerEventIF event) {
|
||||||
handleEvent(sessions,syslogServer,null,packet.getSocketAddress(),event);
|
handleEvent(sessions, syslogServer, null, packet.getSocketAddress(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, Socket socket, SyslogServerEventIF event) {
|
public static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, Socket socket, SyslogServerEventIF event) {
|
||||||
handleEvent(sessions,syslogServer,socket,socket.getRemoteSocketAddress(),event);
|
handleEvent(sessions, syslogServer, socket, socket.getRemoteSocketAddress(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, Socket socket, SocketAddress socketAddress, SyslogServerEventIF event) {
|
protected static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, Socket socket, SocketAddress socketAddress, SyslogServerEventIF event) {
|
||||||
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
||||||
|
|
||||||
for(int i=0; i<eventHandlers.size(); i++) {
|
for (int i = 0; i < eventHandlers.size(); i++) {
|
||||||
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
||||||
|
|
||||||
Object session = (sessions != null && socket != null) ? sessions.getSession(socket,eventHandler) : null;
|
Object session = (sessions != null && socket != null) ? sessions.getSession(socket, eventHandler) : null;
|
||||||
|
|
||||||
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionEventHandlerIF) eventHandler).event(session,syslogServer,socketAddress,event);
|
((SyslogServerSessionEventHandlerIF) eventHandler).event(session, syslogServer, socketAddress, event);
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session,syslogServer,socketAddress,exception);
|
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session, syslogServer, socketAddress, exception);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
@ -298,11 +298,11 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
|
|
||||||
} else if (eventHandler instanceof SyslogServerSessionlessEventHandlerIF) {
|
} else if (eventHandler instanceof SyslogServerSessionlessEventHandlerIF) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionlessEventHandlerIF) eventHandler).event(syslogServer,socketAddress,event);
|
((SyslogServerSessionlessEventHandlerIF) eventHandler).event(syslogServer, socketAddress, event);
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer,socketAddress,exception);
|
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer, socketAddress, exception);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
@ -315,12 +315,12 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
public static void handleException(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception) {
|
public static void handleException(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception) {
|
||||||
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
List eventHandlers = syslogServer.getConfig().getEventHandlers();
|
||||||
|
|
||||||
for(int i=0; i<eventHandlers.size(); i++) {
|
for (int i = 0; i < eventHandlers.size(); i++) {
|
||||||
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
|
||||||
|
|
||||||
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session,syslogServer,socketAddress,exception);
|
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session, syslogServer, socketAddress, exception);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
@ -328,7 +328,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
|
|||||||
|
|
||||||
} else if (eventHandler instanceof SyslogServerSessionlessEventHandlerIF) {
|
} else if (eventHandler instanceof SyslogServerSessionlessEventHandlerIF) {
|
||||||
try {
|
try {
|
||||||
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer,socketAddress,exception);
|
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer, socketAddress, exception);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
|
@ -8,16 +8,16 @@ import org.graylog2.syslog4j.server.SyslogServerConfigIF;
|
|||||||
import org.graylog2.syslog4j.server.SyslogServerEventHandlerIF;
|
import org.graylog2.syslog4j.server.SyslogServerEventHandlerIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractSyslogServerConfig provides a base abstract implementation of the SyslogServerConfigIF
|
* AbstractSyslogServerConfig provides a base abstract implementation of the SyslogServerConfigIF
|
||||||
* configuration interface.
|
* configuration interface.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractSyslogServerConfig.java,v 1.9 2011/01/11 05:11:13 cvs Exp $
|
* @version $Id: AbstractSyslogServerConfig.java,v 1.9 2011/01/11 05:11:13 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSyslogServerConfig implements SyslogServerConfigIF {
|
public abstract class AbstractSyslogServerConfig implements SyslogServerConfigIF {
|
||||||
private static final long serialVersionUID = 870248648801259856L;
|
private static final long serialVersionUID = 870248648801259856L;
|
||||||
|
|
||||||
|
@ -12,15 +12,15 @@ import org.graylog2.syslog4j.server.SyslogServerEventIF;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogServerEvent provides an implementation of the SyslogServerEventIF interface.
|
* SyslogServerEvent provides an implementation of the SyslogServerEventIF interface.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogServerEvent.java,v 1.9 2011/01/11 06:21:15 cvs Exp $
|
* @version $Id: SyslogServerEvent.java,v 1.9 2011/01/11 06:21:15 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SyslogServerEvent implements SyslogServerEventIF {
|
public class SyslogServerEvent implements SyslogServerEventIF {
|
||||||
private static final long serialVersionUID = 6136043067089899962L;
|
private static final long serialVersionUID = 6136043067089899962L;
|
||||||
|
|
||||||
@ -39,16 +39,17 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
protected String message = null;
|
protected String message = null;
|
||||||
protected InetAddress inetAddress = null;
|
protected InetAddress inetAddress = null;
|
||||||
|
|
||||||
protected SyslogServerEvent() { }
|
protected SyslogServerEvent() {
|
||||||
|
}
|
||||||
|
|
||||||
public SyslogServerEvent(final String message, InetAddress inetAddress) {
|
public SyslogServerEvent(final String message, InetAddress inetAddress) {
|
||||||
initialize(message,inetAddress);
|
initialize(message, inetAddress);
|
||||||
|
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyslogServerEvent(final byte[] message, int length, InetAddress inetAddress) {
|
public SyslogServerEvent(final byte[] message, int length, InetAddress inetAddress) {
|
||||||
initialize(message,length,inetAddress);
|
initialize(message, length, inetAddress);
|
||||||
|
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
@ -71,7 +72,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
int i = this.message.indexOf(' ');
|
int i = this.message.indexOf(' ');
|
||||||
|
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
this.host = this.message.substring(0,i).trim();
|
this.host = this.message.substring(0, i).trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +90,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
|
|
||||||
String year = Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
|
String year = Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
|
||||||
|
|
||||||
String originalDate = this.message.substring(0,datelength-1) + " " + year;
|
String originalDate = this.message.substring(0, datelength - 1) + " " + year;
|
||||||
DateFormat dateFormat = new SimpleDateFormat(dateFormatS);
|
DateFormat dateFormat = new SimpleDateFormat(dateFormatS);
|
||||||
try {
|
try {
|
||||||
this.date = dateFormat.parse(originalDate);
|
this.date = dateFormat.parse(originalDate);
|
||||||
@ -109,7 +110,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
int i = this.message.indexOf(">");
|
int i = this.message.indexOf(">");
|
||||||
|
|
||||||
if (i <= 4 && i > -1) {
|
if (i <= 4 && i > -1) {
|
||||||
String priorityStr = this.message.substring(1,i);
|
String priorityStr = this.message.substring(1, i);
|
||||||
|
|
||||||
int priority = 0;
|
int priority = 0;
|
||||||
try {
|
try {
|
||||||
@ -117,7 +118,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
this.facility = priority >> 3;
|
this.facility = priority >> 3;
|
||||||
this.level = priority - (this.facility << 3);
|
this.level = priority - (this.facility << 3);
|
||||||
|
|
||||||
this.message = this.message.substring(i+1);
|
this.message = this.message.substring(i + 1);
|
||||||
|
|
||||||
parseDate();
|
parseDate();
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
|
|
||||||
protected void parse() {
|
protected void parse() {
|
||||||
if (this.message == null) {
|
if (this.message == null) {
|
||||||
this.message = SyslogUtility.newString(this,this.rawBytes,this.rawLength);
|
this.message = SyslogUtility.newString(this, this.rawBytes, this.rawLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
parsePriority();
|
parsePriority();
|
||||||
@ -148,7 +149,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
|
|
||||||
public byte[] getRaw() {
|
public byte[] getRaw() {
|
||||||
if (this.rawString != null) {
|
if (this.rawString != null) {
|
||||||
byte[] rawStringBytes = SyslogUtility.getBytes(this,this.rawString);
|
byte[] rawStringBytes = SyslogUtility.getBytes(this, this.rawString);
|
||||||
|
|
||||||
return rawStringBytes;
|
return rawStringBytes;
|
||||||
|
|
||||||
@ -157,7 +158,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
byte[] newRawBytes = new byte[this.rawLength];
|
byte[] newRawBytes = new byte[this.rawLength];
|
||||||
System.arraycopy(this.rawBytes,0,newRawBytes,0,this.rawLength);
|
System.arraycopy(this.rawBytes, 0, newRawBytes, 0, this.rawLength);
|
||||||
|
|
||||||
return newRawBytes;
|
return newRawBytes;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class FileSyslogServerEventHandler extends PrintStreamSyslogServerEventHa
|
|||||||
protected static PrintStream createPrintStream(String fileName, boolean append) throws IOException {
|
protected static PrintStream createPrintStream(String fileName, boolean append) throws IOException {
|
||||||
File file = new File(fileName);
|
File file = new File(fileName);
|
||||||
|
|
||||||
OutputStream os = new FileOutputStream(file,append);
|
OutputStream os = new FileOutputStream(file, append);
|
||||||
|
|
||||||
PrintStream printStream = new PrintStream(os);
|
PrintStream printStream = new PrintStream(os);
|
||||||
|
|
||||||
@ -20,10 +20,10 @@ public class FileSyslogServerEventHandler extends PrintStreamSyslogServerEventHa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileSyslogServerEventHandler(String fileName) throws IOException {
|
public FileSyslogServerEventHandler(String fileName) throws IOException {
|
||||||
super(createPrintStream(fileName,true));
|
super(createPrintStream(fileName, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileSyslogServerEventHandler(String fileName, boolean append) throws IOException {
|
public FileSyslogServerEventHandler(String fileName, boolean append) throws IOException {
|
||||||
super(createPrintStream(fileName,append));
|
super(createPrintStream(fileName, append));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ import org.graylog2.syslog4j.server.SyslogServerSessionEventHandlerIF;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SystemOutSyslogServerEventHandler provides a simple example implementation
|
* SystemOutSyslogServerEventHandler provides a simple example implementation
|
||||||
* of the SyslogServerEventHandlerIF which writes the events to System.out.
|
* of the SyslogServerEventHandlerIF which writes the events to System.out.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: PrintStreamSyslogServerEventHandler.java,v 1.7 2010/11/28 22:07:57 cvs Exp $
|
* @version $Id: PrintStreamSyslogServerEventHandler.java,v 1.7 2010/11/28 22:07:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class PrintStreamSyslogServerEventHandler implements SyslogServerSessionEventHandlerIF {
|
public class PrintStreamSyslogServerEventHandler implements SyslogServerSessionEventHandlerIF {
|
||||||
private static final long serialVersionUID = 6036415838696050746L;
|
private static final long serialVersionUID = 6036415838696050746L;
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ import org.graylog2.syslog4j.server.impl.event.SyslogServerEvent;
|
|||||||
* SyslogServerStructuredEvent provides an implementation of the
|
* SyslogServerStructuredEvent provides an implementation of the
|
||||||
* SyslogServerEventIF interface that supports receiving of structured syslog
|
* SyslogServerEventIF interface that supports receiving of structured syslog
|
||||||
* messages, as defined in:
|
* messages, as defined in:
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
|
||||||
* </p>
|
* </p>
|
||||||
*
|
* <p/>
|
||||||
* <p>
|
* <p>
|
||||||
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
|
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
|
||||||
* LGPL license is available in the META-INF folder in all distributions of
|
* LGPL license is available in the META-INF folder in all distributions of
|
||||||
@ -38,14 +38,14 @@ public class StructuredSyslogServerEvent extends SyslogServerEvent {
|
|||||||
public StructuredSyslogServerEvent(final byte[] message, int length, InetAddress inetAddress) {
|
public StructuredSyslogServerEvent(final byte[] message, int length, InetAddress inetAddress) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
initialize(message,length,inetAddress);
|
initialize(message, length, inetAddress);
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructuredSyslogServerEvent(final String message, InetAddress inetAddress) {
|
public StructuredSyslogServerEvent(final String message, InetAddress inetAddress) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
initialize(message,inetAddress);
|
initialize(message, inetAddress);
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ public class StructuredSyslogServerEvent extends SyslogServerEvent {
|
|||||||
int i = this.message.indexOf(' ');
|
int i = this.message.indexOf(' ');
|
||||||
|
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
this.host = this.message.substring(0,i).trim();
|
this.host = this.message.substring(0, i).trim();
|
||||||
this.message = this.message.substring(i+1);
|
this.message = this.message.substring(i + 1);
|
||||||
|
|
||||||
parseApplicationName();
|
parseApplicationName();
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public class StructuredSyslogServerEvent extends SyslogServerEvent {
|
|||||||
// throw new SyslogRuntimeException(
|
// throw new SyslogRuntimeException(
|
||||||
// "Message received is not a valid structured message: "
|
// "Message received is not a valid structured message: "
|
||||||
// + getMessage(), e);
|
// + getMessage(), e);
|
||||||
return new StructuredSyslogMessage(null,null,getMessage());
|
return new StructuredSyslogMessage(null, null, getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package org.graylog2.syslog4j.server.impl.net;
|
|||||||
import org.graylog2.syslog4j.server.impl.AbstractSyslogServerConfig;
|
import org.graylog2.syslog4j.server.impl.AbstractSyslogServerConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractNetSyslogServerConfig provides a base abstract implementation of the AbstractSyslogServerConfig
|
* AbstractNetSyslogServerConfig provides a base abstract implementation of the AbstractSyslogServerConfig
|
||||||
* configuration interface.
|
* configuration interface.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: AbstractNetSyslogServerConfig.java,v 1.4 2008/11/07 15:15:41 cvs Exp $
|
* @version $Id: AbstractNetSyslogServerConfig.java,v 1.4 2008/11/07 15:15:41 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractNetSyslogServerConfig extends AbstractSyslogServerConfig {
|
public abstract class AbstractNetSyslogServerConfig extends AbstractSyslogServerConfig {
|
||||||
private static final long serialVersionUID = -3363374941938350263L;
|
private static final long serialVersionUID = -3363374941938350263L;
|
||||||
|
|
||||||
|
@ -20,15 +20,15 @@ import org.graylog2.syslog4j.server.impl.AbstractSyslogServer;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslogServer provides a simple threaded TCP/IP server implementation.
|
* TCPNetSyslogServer provides a simple threaded TCP/IP server implementation.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslogServer.java,v 1.23 2010/11/28 22:07:57 cvs Exp $
|
* @version $Id: TCPNetSyslogServer.java,v 1.23 2010/11/28 22:07:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class TCPNetSyslogServer extends AbstractSyslogServer {
|
public class TCPNetSyslogServer extends AbstractSyslogServer {
|
||||||
public static class TCPNetSyslogSocketHandler implements Runnable {
|
public static class TCPNetSyslogSocketHandler implements Runnable {
|
||||||
protected SyslogServerIF server = null;
|
protected SyslogServerIF server = null;
|
||||||
@ -40,7 +40,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
this.server = server;
|
this.server = server;
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
|
|
||||||
synchronized(this.sessions) {
|
synchronized (this.sessions) {
|
||||||
this.sessions.addSocket(socket);
|
this.sessions.addSocket(socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,13 +54,13 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
|
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
AbstractSyslogServer.handleSessionOpen(this.sessions,this.server,this.socket);
|
AbstractSyslogServer.handleSessionOpen(this.sessions, this.server, this.socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (line != null && line.length() != 0) {
|
while (line != null && line.length() != 0) {
|
||||||
SyslogServerEventIF event = createEvent(this.server.getConfig(),line,this.socket.getInetAddress());
|
SyslogServerEventIF event = createEvent(this.server.getConfig(), line, this.socket.getInetAddress());
|
||||||
|
|
||||||
AbstractSyslogServer.handleEvent(this.sessions,this.server,this.socket,event);
|
AbstractSyslogServer.handleEvent(this.sessions, this.server, this.socket, event);
|
||||||
|
|
||||||
line = br.readLine();
|
line = br.readLine();
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
timeout = true;
|
timeout = true;
|
||||||
|
|
||||||
} catch (SocketException se) {
|
} catch (SocketException se) {
|
||||||
AbstractSyslogServer.handleException(this.sessions,this.server,this.socket.getRemoteSocketAddress(),se);
|
AbstractSyslogServer.handleException(this.sessions, this.server, this.socket.getRemoteSocketAddress(), se);
|
||||||
|
|
||||||
if ("Socket closed".equals(se.getMessage())) {
|
if ("Socket closed".equals(se.getMessage())) {
|
||||||
//
|
//
|
||||||
@ -79,18 +79,18 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
AbstractSyslogServer.handleException(this.sessions,this.server,this.socket.getRemoteSocketAddress(),ioe);
|
AbstractSyslogServer.handleException(this.sessions, this.server, this.socket.getRemoteSocketAddress(), ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AbstractSyslogServer.handleSessionClosed(this.sessions,this.server,this.socket,timeout);
|
AbstractSyslogServer.handleSessionClosed(this.sessions, this.server, this.socket, timeout);
|
||||||
|
|
||||||
this.sessions.removeSocket(this.socket);
|
this.sessions.removeSocket(this.socket);
|
||||||
|
|
||||||
this.socket.close();
|
this.socket.close();
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
AbstractSyslogServer.handleException(this.sessions,this.server,this.socket.getRemoteSocketAddress(),ioe);
|
AbstractSyslogServer.handleException(this.sessions, this.server, this.socket.getRemoteSocketAddress(), ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,11 +136,11 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
this.serverSocket.close();
|
this.serverSocket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized(this.sessions) {
|
synchronized (this.sessions) {
|
||||||
Iterator i = this.sessions.getSockets();
|
Iterator i = this.sessions.getSockets();
|
||||||
|
|
||||||
if (i != null) {
|
if (i != null) {
|
||||||
while(i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Socket s = (Socket) i.next();
|
Socket s = (Socket) i.next();
|
||||||
|
|
||||||
s.close();
|
s.close();
|
||||||
@ -172,14 +172,14 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
if (this.syslogServerConfig.getHost() != null) {
|
if (this.syslogServerConfig.getHost() != null) {
|
||||||
InetAddress inetAddress = InetAddress.getByName(this.syslogServerConfig.getHost());
|
InetAddress inetAddress = InetAddress.getByName(this.syslogServerConfig.getHost());
|
||||||
|
|
||||||
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(),this.tcpNetSyslogServerConfig.getBacklog(),inetAddress);
|
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(), this.tcpNetSyslogServerConfig.getBacklog(), inetAddress);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (this.tcpNetSyslogServerConfig.getBacklog() < 1) {
|
if (this.tcpNetSyslogServerConfig.getBacklog() < 1) {
|
||||||
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort());
|
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(),this.tcpNetSyslogServerConfig.getBacklog());
|
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(), this.tcpNetSyslogServerConfig.getBacklog());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
|
|
||||||
handleInitialize(this);
|
handleInitialize(this);
|
||||||
|
|
||||||
while(!this.shutdown) {
|
while (!this.shutdown) {
|
||||||
try {
|
try {
|
||||||
Socket socket = this.serverSocket.accept();
|
Socket socket = this.serverSocket.accept();
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
TCPNetSyslogSocketHandler handler = new TCPNetSyslogSocketHandler(this.sessions,this,socket);
|
TCPNetSyslogSocketHandler handler = new TCPNetSyslogSocketHandler(this.sessions, this, socket);
|
||||||
|
|
||||||
Thread t = new Thread(handler);
|
Thread t = new Thread(handler);
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@ package org.graylog2.syslog4j.server.impl.net.tcp;
|
|||||||
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
|
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslogServerConfig provides configuration for TCPNetSyslogServer.
|
* TCPNetSyslogServerConfig provides configuration for TCPNetSyslogServer.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslogServerConfig.java,v 1.8 2010/11/28 01:38:08 cvs Exp $
|
* @version $Id: TCPNetSyslogServerConfig.java,v 1.8 2010/11/28 01:38:08 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class TCPNetSyslogServerConfig extends AbstractNetSyslogServerConfig implements TCPNetSyslogServerConfigIF {
|
public class TCPNetSyslogServerConfig extends AbstractNetSyslogServerConfig implements TCPNetSyslogServerConfigIF {
|
||||||
private static final long serialVersionUID = -1546696301177599370L;
|
private static final long serialVersionUID = -1546696301177599370L;
|
||||||
|
|
||||||
|
@ -3,28 +3,32 @@ package org.graylog2.syslog4j.server.impl.net.tcp;
|
|||||||
import org.graylog2.syslog4j.server.SyslogServerConfigIF;
|
import org.graylog2.syslog4j.server.SyslogServerConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCPNetSyslogServerConfigIF provides configuration for TCPNetSyslogServer.
|
* TCPNetSyslogServerConfigIF provides configuration for TCPNetSyslogServer.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: TCPNetSyslogServerConfigIF.java,v 1.3 2010/11/28 01:38:08 cvs Exp $
|
* @version $Id: TCPNetSyslogServerConfigIF.java,v 1.3 2010/11/28 01:38:08 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface TCPNetSyslogServerConfigIF extends SyslogServerConfigIF {
|
public interface TCPNetSyslogServerConfigIF extends SyslogServerConfigIF {
|
||||||
public final static byte MAX_ACTIVE_SOCKETS_BEHAVIOR_BLOCK = 0;
|
public final static byte MAX_ACTIVE_SOCKETS_BEHAVIOR_BLOCK = 0;
|
||||||
public final static byte MAX_ACTIVE_SOCKETS_BEHAVIOR_REJECT = 1;
|
public final static byte MAX_ACTIVE_SOCKETS_BEHAVIOR_REJECT = 1;
|
||||||
|
|
||||||
public int getTimeout();
|
public int getTimeout();
|
||||||
|
|
||||||
public void setTimeout(int timeout);
|
public void setTimeout(int timeout);
|
||||||
|
|
||||||
public int getBacklog();
|
public int getBacklog();
|
||||||
|
|
||||||
public void setBacklog(int backlog);
|
public void setBacklog(int backlog);
|
||||||
|
|
||||||
public int getMaxActiveSockets();
|
public int getMaxActiveSockets();
|
||||||
|
|
||||||
public void setMaxActiveSockets(int maxActiveSockets);
|
public void setMaxActiveSockets(int maxActiveSockets);
|
||||||
|
|
||||||
public byte getMaxActiveSocketsBehavior();
|
public byte getMaxActiveSocketsBehavior();
|
||||||
|
|
||||||
public void setMaxActiveSocketsBehavior(byte maxActiveSocketsBehavior);
|
public void setMaxActiveSocketsBehavior(byte maxActiveSocketsBehavior);
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
|
|||||||
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServer;
|
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslogServer provides a simple threaded TCP/IP server implementation
|
* SSLTCPNetSyslogServer provides a simple threaded TCP/IP server implementation
|
||||||
* which uses SSL/TLS.
|
* which uses SSL/TLS.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslogServer.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslogServer.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SSLTCPNetSyslogServer extends TCPNetSyslogServer {
|
public class SSLTCPNetSyslogServer extends TCPNetSyslogServer {
|
||||||
public void initialize() throws SyslogRuntimeException {
|
public void initialize() throws SyslogRuntimeException {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
@ -28,25 +28,25 @@ public class SSLTCPNetSyslogServer extends TCPNetSyslogServer {
|
|||||||
String keyStore = sslTcpNetSyslogServerConfig.getKeyStore();
|
String keyStore = sslTcpNetSyslogServerConfig.getKeyStore();
|
||||||
|
|
||||||
if (keyStore != null && !"".equals(keyStore.trim())) {
|
if (keyStore != null && !"".equals(keyStore.trim())) {
|
||||||
System.setProperty("javax.net.ssl.keyStore",keyStore);
|
System.setProperty("javax.net.ssl.keyStore", keyStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
String keyStorePassword = sslTcpNetSyslogServerConfig.getKeyStorePassword();
|
String keyStorePassword = sslTcpNetSyslogServerConfig.getKeyStorePassword();
|
||||||
|
|
||||||
if (keyStorePassword != null && !"".equals(keyStorePassword.trim())) {
|
if (keyStorePassword != null && !"".equals(keyStorePassword.trim())) {
|
||||||
System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
|
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
String trustStore = sslTcpNetSyslogServerConfig.getTrustStore();
|
String trustStore = sslTcpNetSyslogServerConfig.getTrustStore();
|
||||||
|
|
||||||
if (trustStore != null && !"".equals(trustStore.trim())) {
|
if (trustStore != null && !"".equals(trustStore.trim())) {
|
||||||
System.setProperty("javax.net.ssl.trustStore",trustStore);
|
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
String trustStorePassword = sslTcpNetSyslogServerConfig.getTrustStorePassword();
|
String trustStorePassword = sslTcpNetSyslogServerConfig.getTrustStorePassword();
|
||||||
|
|
||||||
if (trustStorePassword != null && !"".equals(trustStorePassword.trim())) {
|
if (trustStorePassword != null && !"".equals(trustStorePassword.trim())) {
|
||||||
System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
|
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@ package org.graylog2.syslog4j.server.impl.net.tcp.ssl;
|
|||||||
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServerConfig;
|
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServerConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslogServerConfig provides configuration for SSLTCPNetSyslogServer.
|
* SSLTCPNetSyslogServerConfig provides configuration for SSLTCPNetSyslogServer.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslogServerConfig.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslogServerConfig.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class SSLTCPNetSyslogServerConfig extends TCPNetSyslogServerConfig implements SSLTCPNetSyslogServerConfigIF {
|
public class SSLTCPNetSyslogServerConfig extends TCPNetSyslogServerConfig implements SSLTCPNetSyslogServerConfigIF {
|
||||||
private static final long serialVersionUID = -840102682868286462L;
|
private static final long serialVersionUID = -840102682868286462L;
|
||||||
|
|
||||||
|
@ -3,25 +3,29 @@ package org.graylog2.syslog4j.server.impl.net.tcp.ssl;
|
|||||||
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServerConfigIF;
|
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServerConfigIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSLTCPNetSyslogServerConfigIF provides configuration for SSLTCPNetSyslogServer.
|
* SSLTCPNetSyslogServerConfigIF provides configuration for SSLTCPNetSyslogServer.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SSLTCPNetSyslogServerConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
* @version $Id: SSLTCPNetSyslogServerConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public interface SSLTCPNetSyslogServerConfigIF extends TCPNetSyslogServerConfigIF {
|
public interface SSLTCPNetSyslogServerConfigIF extends TCPNetSyslogServerConfigIF {
|
||||||
public String getKeyStore();
|
public String getKeyStore();
|
||||||
|
|
||||||
public void setKeyStore(String keyStore);
|
public void setKeyStore(String keyStore);
|
||||||
|
|
||||||
public String getKeyStorePassword();
|
public String getKeyStorePassword();
|
||||||
|
|
||||||
public void setKeyStorePassword(String keyStorePassword);
|
public void setKeyStorePassword(String keyStorePassword);
|
||||||
|
|
||||||
public String getTrustStore();
|
public String getTrustStore();
|
||||||
|
|
||||||
public void setTrustStore(String trustStore);
|
public void setTrustStore(String trustStore);
|
||||||
|
|
||||||
public String getTrustStorePassword();
|
public String getTrustStorePassword();
|
||||||
|
|
||||||
public void setTrustStorePassword(String trustStorePassword);
|
public void setTrustStorePassword(String trustStorePassword);
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,15 @@ import org.graylog2.syslog4j.server.impl.AbstractSyslogServer;
|
|||||||
import org.graylog2.syslog4j.util.SyslogUtility;
|
import org.graylog2.syslog4j.util.SyslogUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UDPNetSyslogServer provides a simple non-threaded UDP/IP server implementation.
|
* UDPNetSyslogServer provides a simple non-threaded UDP/IP server implementation.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UDPNetSyslogServer.java,v 1.16 2010/11/12 03:43:15 cvs Exp $
|
* @version $Id: UDPNetSyslogServer.java,v 1.16 2010/11/12 03:43:15 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UDPNetSyslogServer extends AbstractSyslogServer {
|
public class UDPNetSyslogServer extends AbstractSyslogServer {
|
||||||
protected DatagramSocket ds = null;
|
protected DatagramSocket ds = null;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class UDPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
if (this.syslogServerConfig.getHost() != null) {
|
if (this.syslogServerConfig.getHost() != null) {
|
||||||
InetAddress inetAddress = InetAddress.getByName(this.syslogServerConfig.getHost());
|
InetAddress inetAddress = InetAddress.getByName(this.syslogServerConfig.getHost());
|
||||||
|
|
||||||
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort(),inetAddress);
|
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort(), inetAddress);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort());
|
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort());
|
||||||
@ -73,27 +73,27 @@ public class UDPNetSyslogServer extends AbstractSyslogServer {
|
|||||||
|
|
||||||
handleInitialize(this);
|
handleInitialize(this);
|
||||||
|
|
||||||
while(!this.shutdown) {
|
while (!this.shutdown) {
|
||||||
DatagramPacket dp = null;
|
DatagramPacket dp = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dp = new DatagramPacket(receiveData,receiveData.length);
|
dp = new DatagramPacket(receiveData, receiveData.length);
|
||||||
|
|
||||||
this.ds.receive(dp);
|
this.ds.receive(dp);
|
||||||
|
|
||||||
SyslogServerEventIF event = createEvent(this.getConfig(),receiveData,dp.getLength(),dp.getAddress());
|
SyslogServerEventIF event = createEvent(this.getConfig(), receiveData, dp.getLength(), dp.getAddress());
|
||||||
|
|
||||||
handleEvent(null,this,dp,event);
|
handleEvent(null, this, dp, event);
|
||||||
|
|
||||||
} catch (SocketException se) {
|
} catch (SocketException se) {
|
||||||
int i = se.getMessage() == null ? -1 : se.getMessage().toLowerCase().indexOf("socket closed");
|
int i = se.getMessage() == null ? -1 : se.getMessage().toLowerCase().indexOf("socket closed");
|
||||||
|
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
handleException(null,this,dp.getSocketAddress(),se);
|
handleException(null, this, dp.getSocketAddress(), se);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
handleException(null,this,dp.getSocketAddress(),ioe);
|
handleException(null, this, dp.getSocketAddress(), ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@ package org.graylog2.syslog4j.server.impl.net.udp;
|
|||||||
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
|
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UDPNetSyslogServerConfig provides configuration for UDPNetSyslogServer.
|
* UDPNetSyslogServerConfig provides configuration for UDPNetSyslogServer.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: UDPNetSyslogServerConfig.java,v 1.6 2010/10/28 05:10:57 cvs Exp $
|
* @version $Id: UDPNetSyslogServerConfig.java,v 1.6 2010/10/28 05:10:57 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig {
|
public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig {
|
||||||
private static final long serialVersionUID = -2005919161187055486L;
|
private static final long serialVersionUID = -2005919161187055486L;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,16 @@
|
|||||||
package org.graylog2.syslog4j.util;
|
package org.graylog2.syslog4j.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OSDetectUtility provides operating system detection used to determine
|
* OSDetectUtility provides operating system detection used to determine
|
||||||
* whether Syslog4j is running on a Unix platform.
|
* whether Syslog4j is running on a Unix platform.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: OSDetectUtility.java,v 1.4 2008/11/14 04:31:59 cvs Exp $
|
* @version $Id: OSDetectUtility.java,v 1.4 2008/11/14 04:31:59 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public final class OSDetectUtility {
|
public final class OSDetectUtility {
|
||||||
private final static String[] UNIX_PLATFORMS = {
|
private final static String[] UNIX_PLATFORMS = {
|
||||||
"Linux",
|
"Linux",
|
||||||
@ -49,7 +49,7 @@ public final class OSDetectUtility {
|
|||||||
if (osName != null && !"".equals(osName.trim())) {
|
if (osName != null && !"".equals(osName.trim())) {
|
||||||
osName = osName.toLowerCase();
|
osName = osName.toLowerCase();
|
||||||
|
|
||||||
for(int i=0; i<platforms.length; i++) {
|
for (int i = 0; i < platforms.length; i++) {
|
||||||
String platform = platforms[i].toLowerCase();
|
String platform = platforms[i].toLowerCase();
|
||||||
|
|
||||||
if (osName.indexOf(platform) > -1) {
|
if (osName.indexOf(platform) > -1) {
|
||||||
|
@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogConstants;
|
|||||||
import org.graylog2.syslog4j.SyslogRuntimeException;
|
import org.graylog2.syslog4j.SyslogRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SyslogUtility provides several common utility methods used within
|
* SyslogUtility provides several common utility methods used within
|
||||||
* Syslog4j.
|
* Syslog4j.
|
||||||
*
|
* <p/>
|
||||||
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
|
||||||
* of the LGPL license is available in the META-INF folder in all
|
* of the LGPL license is available in the META-INF folder in all
|
||||||
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
|
||||||
*
|
*
|
||||||
* @author <syslog4j@productivity.org>
|
* @author <syslog4j@productivity.org>
|
||||||
* @version $Id: SyslogUtility.java,v 1.21 2010/11/28 01:38:08 cvs Exp $
|
* @version $Id: SyslogUtility.java,v 1.21 2010/11/28 01:38:08 cvs Exp $
|
||||||
*/
|
*/
|
||||||
public final class SyslogUtility implements SyslogConstants {
|
public final class SyslogUtility implements SyslogConstants {
|
||||||
private static final long serialVersionUID = 915031554586613648L;
|
private static final long serialVersionUID = 915031554586613648L;
|
||||||
|
|
||||||
@ -40,29 +40,50 @@ public final class SyslogUtility implements SyslogConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String getFacilityString(int syslogFacility) {
|
public static final String getFacilityString(int syslogFacility) {
|
||||||
switch(syslogFacility) {
|
switch (syslogFacility) {
|
||||||
case FACILITY_KERN: return "kern";
|
case FACILITY_KERN:
|
||||||
case FACILITY_USER: return "user";
|
return "kern";
|
||||||
case FACILITY_MAIL: return "mail";
|
case FACILITY_USER:
|
||||||
case FACILITY_DAEMON: return "daemon";
|
return "user";
|
||||||
case FACILITY_AUTH: return "auth";
|
case FACILITY_MAIL:
|
||||||
case FACILITY_SYSLOG: return "syslog";
|
return "mail";
|
||||||
case FACILITY_LPR: return "lpr";
|
case FACILITY_DAEMON:
|
||||||
case FACILITY_NEWS: return "news";
|
return "daemon";
|
||||||
case FACILITY_UUCP: return "uucp";
|
case FACILITY_AUTH:
|
||||||
case FACILITY_CRON: return "cron";
|
return "auth";
|
||||||
case FACILITY_AUTHPRIV: return "authpriv";
|
case FACILITY_SYSLOG:
|
||||||
case FACILITY_FTP: return "ftp";
|
return "syslog";
|
||||||
case FACILITY_LOCAL0: return "local0";
|
case FACILITY_LPR:
|
||||||
case FACILITY_LOCAL1: return "local1";
|
return "lpr";
|
||||||
case FACILITY_LOCAL2: return "local2";
|
case FACILITY_NEWS:
|
||||||
case FACILITY_LOCAL3: return "local3";
|
return "news";
|
||||||
case FACILITY_LOCAL4: return "local4";
|
case FACILITY_UUCP:
|
||||||
case FACILITY_LOCAL5: return "local5";
|
return "uucp";
|
||||||
case FACILITY_LOCAL6: return "local6";
|
case FACILITY_CRON:
|
||||||
case FACILITY_LOCAL7: return "local7";
|
return "cron";
|
||||||
|
case FACILITY_AUTHPRIV:
|
||||||
|
return "authpriv";
|
||||||
|
case FACILITY_FTP:
|
||||||
|
return "ftp";
|
||||||
|
case FACILITY_LOCAL0:
|
||||||
|
return "local0";
|
||||||
|
case FACILITY_LOCAL1:
|
||||||
|
return "local1";
|
||||||
|
case FACILITY_LOCAL2:
|
||||||
|
return "local2";
|
||||||
|
case FACILITY_LOCAL3:
|
||||||
|
return "local3";
|
||||||
|
case FACILITY_LOCAL4:
|
||||||
|
return "local4";
|
||||||
|
case FACILITY_LOCAL5:
|
||||||
|
return "local5";
|
||||||
|
case FACILITY_LOCAL6:
|
||||||
|
return "local6";
|
||||||
|
case FACILITY_LOCAL7:
|
||||||
|
return "local7";
|
||||||
|
|
||||||
default: return "UNKNOWN";
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,27 +97,48 @@ public final class SyslogUtility implements SyslogConstants {
|
|||||||
_facilityName = facilityName.trim();
|
_facilityName = facilityName.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if("KERN".equalsIgnoreCase(_facilityName)) { return FACILITY_KERN;
|
if ("KERN".equalsIgnoreCase(_facilityName)) {
|
||||||
} else if("USER".equalsIgnoreCase(facilityName)) { return FACILITY_USER;
|
return FACILITY_KERN;
|
||||||
} else if("MAIL".equalsIgnoreCase(facilityName)) { return FACILITY_MAIL;
|
} else if ("USER".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("DAEMON".equalsIgnoreCase(facilityName)) { return FACILITY_DAEMON;
|
return FACILITY_USER;
|
||||||
} else if("AUTH".equalsIgnoreCase(facilityName)) { return FACILITY_AUTH;
|
} else if ("MAIL".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("SYSLOG".equalsIgnoreCase(facilityName)) { return FACILITY_SYSLOG;
|
return FACILITY_MAIL;
|
||||||
} else if("LPR".equalsIgnoreCase(facilityName)) { return FACILITY_LPR;
|
} else if ("DAEMON".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("NEWS".equalsIgnoreCase(facilityName)) { return FACILITY_NEWS;
|
return FACILITY_DAEMON;
|
||||||
} else if("UUCP".equalsIgnoreCase(facilityName)) { return FACILITY_UUCP;
|
} else if ("AUTH".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("CRON".equalsIgnoreCase(facilityName)) { return FACILITY_CRON;
|
return FACILITY_AUTH;
|
||||||
} else if("AUTHPRIV".equalsIgnoreCase(facilityName)) { return FACILITY_AUTHPRIV;
|
} else if ("SYSLOG".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("FTP".equalsIgnoreCase(facilityName)) { return FACILITY_FTP;
|
return FACILITY_SYSLOG;
|
||||||
} else if("LOCAL0".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL0;
|
} else if ("LPR".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("LOCAL1".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL1;
|
return FACILITY_LPR;
|
||||||
} else if("LOCAL2".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL2;
|
} else if ("NEWS".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("LOCAL3".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL3;
|
return FACILITY_NEWS;
|
||||||
} else if("LOCAL4".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL4;
|
} else if ("UUCP".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("LOCAL5".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL5;
|
return FACILITY_UUCP;
|
||||||
} else if("LOCAL6".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL6;
|
} else if ("CRON".equalsIgnoreCase(facilityName)) {
|
||||||
} else if("LOCAL7".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL7;
|
return FACILITY_CRON;
|
||||||
} else { return -1;
|
} else if ("AUTHPRIV".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_AUTHPRIV;
|
||||||
|
} else if ("FTP".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_FTP;
|
||||||
|
} else if ("LOCAL0".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL0;
|
||||||
|
} else if ("LOCAL1".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL1;
|
||||||
|
} else if ("LOCAL2".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL2;
|
||||||
|
} else if ("LOCAL3".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL3;
|
||||||
|
} else if ("LOCAL4".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL4;
|
||||||
|
} else if ("LOCAL5".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL5;
|
||||||
|
} else if ("LOCAL6".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL6;
|
||||||
|
} else if ("LOCAL7".equalsIgnoreCase(facilityName)) {
|
||||||
|
return FACILITY_LOCAL7;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,15 +152,24 @@ public final class SyslogUtility implements SyslogConstants {
|
|||||||
_levelName = levelName.trim();
|
_levelName = levelName.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if("DEBUG".equalsIgnoreCase(_levelName)) { return LEVEL_DEBUG;
|
if ("DEBUG".equalsIgnoreCase(_levelName)) {
|
||||||
} else if("INFO".equalsIgnoreCase(_levelName)) { return LEVEL_INFO;
|
return LEVEL_DEBUG;
|
||||||
} else if("NOTICE".equalsIgnoreCase(_levelName)) { return LEVEL_NOTICE;
|
} else if ("INFO".equalsIgnoreCase(_levelName)) {
|
||||||
} else if("WARN".equalsIgnoreCase(_levelName)) { return LEVEL_WARN;
|
return LEVEL_INFO;
|
||||||
} else if("ERROR".equalsIgnoreCase(_levelName)) { return LEVEL_ERROR;
|
} else if ("NOTICE".equalsIgnoreCase(_levelName)) {
|
||||||
} else if("CRITICAL".equalsIgnoreCase(_levelName)) { return LEVEL_CRITICAL;
|
return LEVEL_NOTICE;
|
||||||
} else if("ALERT".equalsIgnoreCase(_levelName)) { return LEVEL_ALERT;
|
} else if ("WARN".equalsIgnoreCase(_levelName)) {
|
||||||
} else if("EMERGENCY".equalsIgnoreCase(_levelName)) { return LEVEL_EMERGENCY;
|
return LEVEL_WARN;
|
||||||
} else { return -1;
|
} else if ("ERROR".equalsIgnoreCase(_levelName)) {
|
||||||
|
return LEVEL_ERROR;
|
||||||
|
} else if ("CRITICAL".equalsIgnoreCase(_levelName)) {
|
||||||
|
return LEVEL_CRITICAL;
|
||||||
|
} else if ("ALERT".equalsIgnoreCase(_levelName)) {
|
||||||
|
return LEVEL_ALERT;
|
||||||
|
} else if ("EMERGENCY".equalsIgnoreCase(_levelName)) {
|
||||||
|
return LEVEL_EMERGENCY;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +213,7 @@ public final class SyslogUtility implements SyslogConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String newString(SyslogCharSetIF syslogCharSet, byte[] dataBytes) {
|
public static final String newString(SyslogCharSetIF syslogCharSet, byte[] dataBytes) {
|
||||||
String data = newString(syslogCharSet,dataBytes,dataBytes.length);
|
String data = newString(syslogCharSet, dataBytes, dataBytes.length);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -171,7 +222,7 @@ public final class SyslogUtility implements SyslogConstants {
|
|||||||
String data = null;
|
String data = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = new String(dataBytes,0,dataLength,syslogCharSet.getCharSet());
|
data = new String(dataBytes, 0, dataLength, syslogCharSet.getCharSet());
|
||||||
|
|
||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
data = new String(dataBytes);
|
data = new String(dataBytes);
|
||||||
@ -181,15 +232,23 @@ public final class SyslogUtility implements SyslogConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String getLevelString(int level) {
|
public static final String getLevelString(int level) {
|
||||||
switch(level) {
|
switch (level) {
|
||||||
case SyslogConstants.LEVEL_DEBUG: return "DEBUG";
|
case SyslogConstants.LEVEL_DEBUG:
|
||||||
case SyslogConstants.LEVEL_INFO: return "INFO";
|
return "DEBUG";
|
||||||
case SyslogConstants.LEVEL_NOTICE: return "NOTICE";
|
case SyslogConstants.LEVEL_INFO:
|
||||||
case SyslogConstants.LEVEL_WARN: return "WARN";
|
return "INFO";
|
||||||
case SyslogConstants.LEVEL_ERROR: return "ERROR";
|
case SyslogConstants.LEVEL_NOTICE:
|
||||||
case SyslogConstants.LEVEL_CRITICAL: return "CRITICAL";
|
return "NOTICE";
|
||||||
case SyslogConstants.LEVEL_ALERT: return "ALERT";
|
case SyslogConstants.LEVEL_WARN:
|
||||||
case SyslogConstants.LEVEL_EMERGENCY: return "EMERGENCY";
|
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:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user