I've used log-4-j version 2.3 in my web application. Everything is good but Unicode character are logged as '?' in destination file. How can I set character encoding as Unicode 8 to prevent this problem? here is my sample code : I've wrote a main method to run my test on eclipse it worked properly.but when is run this jeryey web service from from browser (my app server is weblogic), all persian characters are appeard as '?' in the log file:
public static void main(String[] args ) {
UserRestServices service = new UserRestServices();
service.test();
}
@Path("test")
@GET
public String test() {
String newString;
try {
newString = new String("فارسی".getBytes(), "UTF8");
APLogManager.infoLogger.info(newString);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "test compeleted";
}
You can set the charset of the layout. For example:
<PatternLayout
charset="UTF-8"
pattern="%d %p %c{1.} [%t] %m%n" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With