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 "Oleg A. Paraschenko" <ol...@sportwetten.spb.ru> on 2002/03/25 14:37:53 UTC
support of file.encoding system property
Hello!
I'm using jakarta-log4j-1.1.3 and I wish to write logs in unicode. I'm setting java system property 'file.encoding' to 'UTF8', but I get '????" instead of UTF8 on output. Please revise my code, maybe I am doing something wrong.
I looked at archives, but did not understand if 1.1.3 supports this property. I don't like to use alpha of 1.2.
It seems also that someone already implemented log writer with file.encoding property. Is it possible to share implementation?
Thank you in advace.
$ java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Classic VM (build 1.3.0, J2RE 1.3.0 IBM build cx130-20020124 (JIT enabled: jitc))
$ cat test.java
import org.apache.log4j.Category;
import org.apache.log4j.BasicConfigurator;
public class test {
static Category logger = Category.getInstance(test.class);
static void main (String[] args) throws Throwable {
String str = new String("\u65e5\u672c\u8a9e\u6587\u5b57\u5217");
BasicConfigurator.configure();
logger.debug(str);
}
}
$ javac test.java
$ java -Dfile.encoding=UTF8 test
0 [main] DEBUG test - ??????
$
Bye!
--
Oleg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: support of file.encoding system property
Posted by "Oleg A. Paraschenko" <ol...@sportwetten.spb.ru>.
Hello T Master,
thank you for comments.
On Mon, 25 Mar 2002 09:31:48 -0700
"T Master" <tm...@iknowledge.com> wrote:
>
>
> Log the output to a file..... then open the file in an editor supporting UTF-8
> chars e.g. IE browser.
> Your console doesn't support UTF-8 characters, hence you see "????".
No, it seems that problem is not in console. I modified code to use FileAppender and still get "?????" in output file. Please look at it, maybe I missed something obvious.
>
> log4jv1.2 is beta now. beta 5 I believe. Not alpha.
>
Yes, thank you for pointing. It is really not-first beta. I will look if it is possible to use 1.2 without modification of code.
Bye!
--
Oleg
Updated code for testing "?????":
$ cat test.java
import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;
public class test {
static Category logger = Category.getInstance(test.class);
static void main (String[] args) throws Throwable {
String str = new String("\u65e5\u672c\u8a9e\u6587\u5b57\u5217");
PropertyConfigurator.configure("log4j.opt");
logger.debug(str);
}
}
$ cat log4j.opt
log4j.rootCategory=debug, A
log4j.appender.A=org.apache.log4j.FileAppender
log4j.appender.A.File=test.log
log4j.appender.A.Append=false
log4j.appender.A.layout=org.apache.log4j.PatternLayout
$ javac test.java
$ java -Dfile.encoding=UTF8 test
$ cat test.log
??????
$ od -a test.log
0000000 ? ? ? ? ? ? nl
0000007
$ od -b test.log
0000000 077 077 077 077 077 077 012
0000007
$
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: support of file.encoding system property
Posted by T Master <tm...@iknowledge.com>.
Log the output to a file..... then open the file in an editor supporting UTF-8
chars e.g. IE browser.
Your console doesn't support UTF-8 characters, hence you see "????".
log4jv1.2 is beta now. beta 5 I believe. Not alpha.
----- Original Message -----
From: "Oleg A. Paraschenko" <ol...@sportwetten.spb.ru>
To: <lo...@jakarta.apache.org>
Sent: Monday, March 25, 2002 6:37 AM
Subject: support of file.encoding system property
> Hello!
>
> I'm using jakarta-log4j-1.1.3 and I wish to write logs in unicode. I'm
setting java system property 'file.encoding' to 'UTF8', but I get '????" instead
of UTF8 on output. Please revise my code, maybe I am doing something wrong.
> I looked at archives, but did not understand if 1.1.3 supports this
property. I don't like to use alpha of 1.2.
> It seems also that someone already implemented log writer with file.encoding
property. Is it possible to share implementation?
>
> Thank you in advace.
>
> $ java -version
> java version "1.3.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
> Classic VM (build 1.3.0, J2RE 1.3.0 IBM build cx130-20020124 (JIT enabled:
jitc))
> $ cat test.java
> import org.apache.log4j.Category;
> import org.apache.log4j.BasicConfigurator;
>
> public class test {
> static Category logger = Category.getInstance(test.class);
> static void main (String[] args) throws Throwable {
> String str = new String("\u65e5\u672c\u8a9e\u6587\u5b57\u5217");
> BasicConfigurator.configure();
> logger.debug(str);
> }
> }
> $ javac test.java
> $ java -Dfile.encoding=UTF8 test
> 0 [main] DEBUG test - ??????
> $
>
> Bye!
>
> --
> Oleg
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>