ASF Bugzilla – Attachment 28481 Details for
Bug 49177
SyslogAppender: Make the maximum package size configurable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
SyslogAppender and SyslogWriter patch
syslogappender.patch (text/plain), 3.28 KB, created by
charlie
on 2012-03-16 15:02:15 UTC
(
hide
)
Description:
SyslogAppender and SyslogWriter patch
Filename:
MIME Type:
Creator:
charlie
Created:
2012-03-16 15:02:15 UTC
Size:
3.28 KB
patch
obsolete
>Index: src/main/java/org/apache/log4j/helpers/SyslogWriter.java >=================================================================== >--- src/main/java/org/apache/log4j/helpers/SyslogWriter.java (revision 1301564) >+++ src/main/java/org/apache/log4j/helpers/SyslogWriter.java (working copy) >@@ -36,6 +36,8 @@ > */ > public class SyslogWriter extends Writer { > >+ public static final int DEFAULT_MAX_PACKET_LENGTH = 1024; >+ > final int SYSLOG_PORT = 514; > /** > * Host string from last constructed SyslogWriter. >@@ -46,6 +48,7 @@ > private InetAddress address; > private final int port; > private DatagramSocket ds; >+ private int maxPacketLength = DEFAULT_MAX_PACKET_LENGTH; > > /** > * Constructs a new instance of SyslogWriter. >@@ -124,8 +127,8 @@ > // syslog packets must be less than 1024 bytes > // > int bytesLength = bytes.length; >- if (bytesLength >= 1024) { >- bytesLength = 1024; >+ if (bytesLength >= maxPacketLength) { >+ bytesLength = maxPacketLength; > } > DatagramPacket packet = new DatagramPacket(bytes, bytesLength, > address, port); >@@ -135,6 +138,16 @@ > } > > public >+ void setMaxPacketLength(int max) { >+ maxPacketLength = max; >+ } >+ >+ public >+ int getMaxPacketLength() { >+ return maxPacketLength; >+ } >+ >+ public > void flush() {} > > public void close() { >Index: src/main/java/org/apache/log4j/net/SyslogAppender.java >=================================================================== >--- src/main/java/org/apache/log4j/net/SyslogAppender.java (revision 1301564) >+++ src/main/java/org/apache/log4j/net/SyslogAppender.java (working copy) >@@ -97,9 +97,11 @@ > int syslogFacility = LOG_USER; > String facilityStr; > boolean facilityPrinting = false; >+ int maxPacketLength = SyslogWriter.DEFAULT_MAX_PACKET_LENGTH; > > //SyslogTracerPrintWriter stp; > SyslogQuietWriter sqw; >+ SyslogWriter sw; > String syslogHost; > > /** >@@ -283,7 +285,7 @@ > // 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 <= (maxPacketLength-5)) { > sqw.write(packet); > } else { > int split = header.length() + (packet.length() - header.length())/2; >@@ -388,8 +390,9 @@ > */ > public > void setSyslogHost(final String syslogHost) { >- this.sqw = new SyslogQuietWriter(new SyslogWriter(syslogHost), >- syslogFacility, errorHandler); >+ this.sw = new SyslogWriter(syslogHost); >+ sw.setMaxPacketLength(maxPacketLength); >+ this.sqw = new SyslogQuietWriter(sw, syslogFacility, errorHandler); > //this.stp = new SyslogTracerPrintWriter(sqw); > this.syslogHost = syslogHost; > } >@@ -403,6 +406,24 @@ > } > > /** >+ */ >+ public >+ void setMaxPacketLength(final int maxPacketLength) { >+ this.maxPacketLength = maxPacketLength; >+ if (sw != null) { >+ sw.setMaxPacketLength(maxPacketLength); >+ } >+ } >+ >+ /** >+ Returns the value of the <b>SyslogHost</b> option. >+ */ >+ public >+ int getMaxPacketLength() { >+ return maxPacketLength; >+ } >+ >+ /** > Set the syslog facility. This is the <b>Facility</b> option. > > <p>The <code>facilityName</code> parameter must be one of the
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 49177
:
25364
| 28481