加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

更改在docker中运行的selenium节点的日志级别

发布时间:2020-12-16 03:49:55 所属栏目:安全 来源:网络整理
导读:我们的团队正在使用docker部署selenium网格.默认日志级别似乎设置为INFO.我想将它设置为更高,严重或完全关闭它们.我做了三次尝试,但到目前为止,没有任何效果. 方法一: 从selenium客户端,我试图在DesiredCapabilities中的RemoteWebDriver上设置LoggingPrefer

我们的团队正在使用docker部署selenium网格.默认日志级别似乎设置为INFO.我想将它设置为更高,严重或完全关闭它们.我做了三次尝试,但到目前为止,没有任何效果.

方法一:

从selenium客户端,我试图在DesiredCapabilities中的RemoteWebDriver上设置LoggingPreferences:

DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.BROWSER,Level.SEVERE);
logs.enable(LogType.CLIENT,Level.SEVERE);
ogs.enable(LogType.DRIVER,Level.SEVERE);
logs.enable(LogType.SERVER,Level.SEVERE);
desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS,logs);
desiredCapabilities.setCapability(FirefoxDriver.PROFILE,profile);
WebDriver driver = new RemoteWebDriver(new URL(host:4444/wd/hub"),desiredCapabilities);

方法2:我尝试更改配置文件首选项:

FirefoxProfile profile = new FirefoxProfile();

profile.setPreference("webdriver.log.driver","OFF");
profile.setPreference("webdriver.log.file","/dev/null");

方法3:我尝试修改位于/opt/selenium/config.json的容器中的config.json:

{
  "capabilities": [
    {
      "browserName": "*firefox","maxInstances": 1,"seleniumProtocol": "Selenium"
    },{
      "browserName": "firefox","seleniumProtocol": "WebDriver"
    }
  ],"configuration": {
      "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy","maxSession": 1,"port": 5555,"register": true,"registerCycle": 5000,"logLevel":FATAL
  }
}

到目前为止,我一直无法做任何改变日志记录行为的事情.

最佳答案
@Scott

Selenium代码库使用Java Utils Logger.所以也许你可以尝试传递一个自定义的logging.properties,其中日志级别被提升,看看是否有帮助. [请参阅here以了解有关logging.properties的更多信息]

LoggingPreferences类主要用于调整仅针对给定会话检索的日志级别[至少是我认为的那样]并且它不会改变节点/网格运行的JVM的日志记录级别.

对于Selenium服务器独立,可以通过JVM参数“selenium.LOGGER.level”更改日志级别

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读