Bug 9285 - SyslogWriter 's bug for multibyte enviroment
Summary: SyslogWriter 's bug for multibyte enviroment
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: Sun Solaris
: P3 normal
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2002-05-21 13:32 UTC by Mamoru Kadota
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Mamoru Kadota 2002-05-21 13:32:01 UTC

I'm using log4j package(Version is 1.2.1) in project.
As Happen, when I used SyslogAppender and SyslogWriter for syslogd.
Written word is unperfectly to syslogd's "messages" file.
This word is so short than I expect that.

I thought, it's a enviroment problem with unicode.
Because I use log4j on multibyte enviroment.
(Spec:Fujitsu Solalis SunBlade 1000)
Then, I read log4j package's sources. I detected un-appropiate codes.

Next code is referd for "SyslogWriter.java".

>  public
>  void write(String string) throws IOException {
>    DatagramPacket packet = new DatagramPacket(string.getBytes(),
>        string.length(), 
>        address, SYSLOG_PORT);
>    if(this.ds != null)
>      ds.send(packet);
>  }

"DatagramPacket()" 's second parameter is "string.length()".
But I thought. This suitable code is "string.getBytes().length".
Comment 1 Ceki Gulcu 2002-05-24 11:48:00 UTC
Mr. Kadota,

You are absolutely right. The computation of the byte array length is wrong.
Just fixed in CVS. The fix will be available in log4j 1.2.3 when that is 
released. Thank you for the very professionnal bug report. 
Comment 2 Mamoru Kadota 2002-05-24 15:30:09 UTC
I appreciate your quickly response.
Thank you.