On Jan 26, 2009, at 4:12 AM, Mohammed Mansoor wrote:
Our application takes a backup of files selected from the folders
specified
by the user.
The backup log is written using the Log4j (log4j-1.2.11.jar).
When the backup is taken in Chinese language, the backup log is
written and
it shows question marks(??) in place of the backup details. We tried
using
the appender UTF-8 in the log4j properties as shown below,
log4j.appender.BackupFile.Encoding=UTF-8
We also tried using ISO-8859-1 and Shift_JIS in place of UTF-8. But
that
didn't help. We still get garbled characters for the text written in
the
backup log. Can you please suggest on this. Thanks!!
Please don't post to both log4j-dev and log4j-user.
There are not enough details in your report to troubleshoot.
ISO-8859-1 is the Latin 1 character set and can only represent Unicode
code points from 0 to 255. Any attempt to write an Chinese character
would be expected to produce a ? since the attempt to convert the
character to the encoding will fail and log4j substitutes a "?" when
charset encoding fails.
Since the "J" in Shift_JIS stands for Japanese, it seems reasonable to
think that an attempt to encode a Chinese character would also fail.
UTF-8 is capable of representing any Unicode code point, so you should
not expect a charset encoding failure. However, it is possible that
whatever you are using to display the file is assuming a different
character set, so valid UTF-8 sequence is incorrectly interpreted,
however typically this would be displayed as 2-3 symbols or accented
characters.
Since it appears that you are able to reproduce the problem. I would
suggest:
1) Try log4j 1.2.15. If there is a log4j issue, it may have already
be fixed.
2) Try UTF-16 encoding. That will eliminate the ambiguity on the
encoding.
3) Try UTF-8 encoding again, but examine the output with a hex editor
(for example: ghex or 0xED) to check what bytes are being written to
the file.
4) Try build the SVN HEAD on your platform. The unit tests contain
several tests of encoding and decoding. If those fail on your
platform, then it may be an issue with your JVM.
If you are still seeing a problem, it would be good to get a full
report including a test app, configuration file, the problematic
output and details of your configuration (OS version and vendor, JVM
version and vendor, etc).
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]