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

本小妞迷上赌 提交于 2020-02-07 09:57:15

问题


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 log4j.properties file, just added two lines:

log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.encoding=UTF-16

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?


回答1:


Can you try Reporter#log(new String(s, "UTF-16"), level); in the API? See String API for details.




回答2:


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



来源:https://stackoverflow.com/questions/27013487/how-to-change-testng-reporter-log-encoding-to-utf-16

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!