You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Curt Arnold <ca...@apache.org> on 2006/07/27 17:16:00 UTC

Re: unicode support for log4j

On Jul 27, 2006, at 9:09 AM, Hardik Amarshibhai Patel wrote:

>
> Hi all,
>
> I am working I18N of log4j. So when i enter unicode data it should
> display in right format in Output file.
> In this example i am using UI.java file to take multibyte data from
> Swing application & passing to LOGGER,
> but in the Output file it is displaying as junk charcter.
> I m sending all 4 files contain at the end.
>
> Please help me in this matter ASAP.
>
> Thank in advance.
>
....

> 4 )  Outpu.log file
>
>  ERROR 27 Jul 2006 17:55:18 - Username::??
>  ERROR 27 Jul 2006 17:55:18 - Password::???
>  FATAL 27 Jul 2006 17:55:18 - This is End of Function :: Fatal Message
> using writeLog()
>  ERROR 27 Jul 2006 17:58:40 - Username::sdfs
>  ERROR 27 Jul 2006 17:58:40 - Password::sdf
>  FATAL 27 Jul 2006 17:58:40 - This is End of Function :: Fatal Message
> using writeLog()
>
> warm regards,
> Hardik Patel


I strongly suspect that the problem is either:

a) your default encoding is ISO-8859-1 (aka Latin 1 or Cp1252 on  
Windows) and the characters that you are emitted can not be  
represented in that encoding.
b) the file is being correctly written in UTF-8 and your editor  
assumes that it is in the default encoding and displays it incorrectly.

My first suggestion would be to explicitly set the encoding to  
"UTF-16" (which can be done in the configuration file) and open it  
with a compatible editor (for example, WordPad on Windows).  It is  
far less likely that there would be an encoding mismatch with a 2- 
byte encoding since the only commonly used encodings are the little  
endian and big endian varieties of UTF-16.

If that works (which it should) then set the encoding to "UTF-8" and  
use an editor that allows you to specify the encoding in use when the  
file is open (for example, later versions of Visual Studio or Kate).

If you are using an earlier version of log4j, please check if the  
problem still exists on the latest release or if possible the SVN  
version of the code.

If you still have problems, then please include the following  
information on your follow up message:

version of log4j
platform
editor/viewer used to display the file
code points of the expected characters
A hex dump of the generated file

The log4j unit tests have several tests to check the correct handling  
of encoding issues.  If you are able to run the unit test, please  
report if those tests fail.

To test your editor, open http://svn.apache.org/repos/asf/logging/ 
log4j/trunk/tests/witness/encoding/ in a browser and download  
UTF-8.log and UTF-16.log.  The files should have identical content  
displayed if you specify UTF-8 as the encoding for your editor.  The  
second line in the file should contain a superscript one and the  
third should a latin A, one character each from Arabic, Armenian,  
Begali, CJK and Cyrillic.  The last two are similar in shape to a T  
and E.  Likely not all will display due to missing fonts.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org