Skip to content
This repository has been archived by the owner. It is now read-only.

SyslogAppender - let max message size be configurable #1

Merged
merged 1 commit into from Apr 22, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

SyslogAppender - let max message size be configurable

  • Loading branch information
Vinh Nguyen
Vinh Nguyen committed Apr 22, 2015
commit 3ee1928565f5ff64ff3ffe08c81aec074d32d13d
@@ -102,6 +102,11 @@
SyslogQuietWriter sqw;
String syslogHost;

// RFC 3164 limit is 1024 bytes, but new implementations may support larger limits.
// Allow for 5 characters in the PRI section added by SyslogQuietWriter.
// See splitPacket().
int maxMessageBytes = 1019;

/**
* If true, the appender will generate the HEADER (timestamp and host name)
* part of the syslog packet.
@@ -283,7 +288,7 @@ private void splitPacket(final String header, final String packet) {
// of 1024 bytes, then write it
// (must allow for up 5to 5 characters in the PRI section
// added by SyslogQuietWriter)
if (byteCount <= 1019) {
if (byteCount <= maxMessageBytes) {
sqw.write(packet);
} else {
int split = header.length() + (packet.length() - header.length())/2;
@@ -533,4 +538,22 @@ private void sendLayoutMessage(final String msg) {
sqw.write(packet);
}
}

/**
* @return The max syslog message size in bytes.
*/
public int getMaxMessageBytes() {
// Allow for 5 characters in the PRI section added by SyslogQuietWriter.
// See splitPacket().
return maxMessageBytes + 5;
}

/**
* @param len The max syslog message size in bytes.
*/
public void setMaxMessageBytes(int len) {
// Allow for 5 characters in the PRI section added by SyslogQuietWriter.
// See splitPacket().
this.maxMessageBytes = len - 5;
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.