更改在docker运行的硒节点的日志级别 [英] Changing the log level for a selenium node running in docker
问题描述
方法一:
从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驱动程序=新的RemoteWebDriver(新URL(主机: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:
{
capabilities:[
{
browserName :* firefox,
maxInstances:1,
seleniumProtocol:Selenium
},
{
browserName:firefox
maxInstances:1,
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,其中日志级别被突破,看看是否有帮助。 [见这里更多地了解logging.properties]
LoggingPreferences类主要用于调整仅针对给定会话检索的日志级别[至少是我认为是],它不会改变节点/网格运行的JVM的日志记录级别。
在Selenium服务器独立的情况下,日志级别可以通过JVM参数selenium.LOGGER.level更改
Our team is deploying a selenium grid using docker. The default log level appears to be set to INFO. I'd like to set it to something higher, SEVERE or turn them completely off. I've made three attempts, but so far, to no effect.
Method One:
From the selenium client, I've tried to set LoggingPreferences on the RemoteWebDriver within DesiredCapabilities:
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);
Method 2: I tried to change the profile preferences:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("webdriver.log.driver", "OFF");
profile.setPreference("webdriver.log.file","/dev/null");
Method 3: I tried to modify config.json in the container located in /opt/selenium/config.json:
{
"capabilities": [
{
"browserName": "*firefox",
"maxInstances": 1,
"seleniumProtocol": "Selenium"
},
{
"browserName": "firefox",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5555,
"register": true,
"registerCycle": 5000,
"logLevel":FATAL
}
}
So far I've been unable to do anything that has altered the logging behavior.
@Scott
The Selenium codebase uses the Java Utils Logger. So maybe you can try passing in a custom logging.properties wherein the log levels are bumped up and see if that helps. [ See here to know a bit more about logging.properties ]
The LoggingPreferences class is mainly used to tweak the log levels that are to be retrieved only for a given session [ atleast that's what I think it is ] and it doesn't alter the logging level of the JVM that the node/grid runs under.
In the case of Selenium server standalone, the log levels can be changed via the JVM argument "selenium.LOGGER.level"
这篇关于更改在docker运行的硒节点的日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!