Shubhasmit Gupta Shubhasmit Gupta - 1 year ago 124
Java Question

How to change testNG Reporter.log() encoding to UTF-16

I am using testNG with selenium. I have two kind of logger, one is log4j logger and the other is testNG Reporter.log(). Now the problem is I need to log some Chinese text. But it is coming as '????' instead of Chinese text. So I changed the file, just added two lines:


Now in my log4j logs it is coming properly but in testNG Reporter.log() it's still coming as '?????'.

Log4j log: Typed text '美联泰'

TestNG Reporter.log(): Typed text '???'

How to set testNG Reporter.log() encoding to UTF-16?

Answer Source

I tried something else and now it's working. Just added JAVA_TOOL_OPTIONS environment variable. Variable name: JAVA_TOOL_OPTIONS Variable value: -Dfile.encoding=UTF8

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download