Here is the patch re-worked for adding charset support for the SyslogAppender. It accepts the optional property CharSet, useful for EBCDIC systems logging to an ASCII based syslog.
Thanks for the info on activateOptions(). Thanks.
--- org-SyslogAppender.java 2003-07-09 17:01:30.000000000 -0500 +++ SyslogAppender.java 2003-07-10 19:07:37.000000000 -0500 @@ -84,6 +84,7 @@ //SyslogTracerPrintWriter stp; SyslogQuietWriter sqw; String syslogHost; + String CharSet; public SyslogAppender() { @@ -259,11 +260,13 @@ } /** - This method returns immediately as options are activated when they - are set. + Create the SyslogQuietWriter object with the requested options */ public void activateOptions() { + this.sqw = new SyslogQuietWriter(new SyslogWriter(syslogHost,CharSet), + syslogFacility, errorHandler); + //this.stp = new SyslogTracerPrintWriter(sqw); } /** @@ -285,13 +288,20 @@ */ public void setSyslogHost(String syslogHost) { - this.sqw = new SyslogQuietWriter(new SyslogWriter(syslogHost), - syslogFacility, errorHandler); - //this.stp = new SyslogTracerPrintWriter(sqw); this.syslogHost = syslogHost; } /** + The <b>Charset</b> option is the name of the charset for + the receiving host. Usefull for EBCDIC to ASCII translation. + + */ + public + void setCharset(String CharSet) { + this.CharSet = CharSet; + } + + /** Returns the value of the <b>SyslogHost</b> option. */ public @@ -300,6 +310,14 @@ } /** + Returns the value of the <b>Charset</b> option. + */ + public + String getCharset() { + return CharSet; + } + + /** Set the syslog facility. This is the <b>Facility</b> option. <p>The <code>facilityName</code> parameter must be one of the
--- org-SyslogWriter.java 2003-07-09 17:01:36.000000000 -0500 +++ SyslogWriter.java 2003-07-10 18:08:01.000000000 -0500 @@ -27,13 +27,15 @@ final int SYSLOG_PORT = 514; static String syslogHost; + static String CharSet; private InetAddress address; private DatagramSocket ds; public - SyslogWriter(String syslogHost) { + SyslogWriter(String syslogHost, String CharSet) { this.syslogHost = syslogHost; + this.CharSet = CharSet; try { this.address = InetAddress.getByName(syslogHost); @@ -61,7 +63,13 @@ public void write(String string) throws IOException { - byte[] bytes = string.getBytes(); + byte[] bytes = null; + + if (CharSet != null) + bytes = string.getBytes(CharSet); + else + bytes = string.getBytes(); + DatagramPacket packet = new DatagramPacket(bytes, bytes.length, address, SYSLOG_PORT);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]