如何将testNG Reporter.log()编码更改为UTF-16 [英] How to change testNG Reporter.log() encoding to UTF-16

查看:213
本文介绍了如何将testNG Reporter.log()编码更改为UTF-16的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将testNG与硒一起使用.我有两种记录器,一种是 log4j 记录器,另一种是 testNG Reporter.log().现在的问题是我需要记录一些中文文本.但是它以"????"的形式出现.而不是中文文本.因此,我更改了log4j.properties文件,仅添加了两行:

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

现在在我的log4j日志中,它可以正常运行,但在testNG Reporter.log()中,它仍以'??????'形式出现.

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

Log4j日志:键入文本美联泰"

TestNG Reporter.log():输入文本"???"

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

如何将testNG Reporter.log()编码设置为UTF-16?

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

推荐答案

我尝试了其他操作,现在可以使用了.刚刚添加了JAVA_TOOL_OPTIONS环境变量.变量名称:JAVA_TOOL_OPTIONS变量值:-Dfile.encoding=UTF8

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

这篇关于如何将testNG Reporter.log()编码更改为UTF-16的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆