Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the level of geckodriver log? #362

Closed
iamcodylee opened this issue Nov 24, 2016 · 13 comments
Closed

How to set the level of geckodriver log? #362

iamcodylee opened this issue Nov 24, 2016 · 13 comments

Comments

@iamcodylee
Copy link

I'm now working on geckodriver 0.11.1
each time I start up my scripts there comes a lot of geckodriver log w/c I won't use forever.
I just read the change log and try to add an argument in my scripts, but didn't work.
can anybody out there inform me how to set the level log of geckodriver via scripts?

@andreastt
Copy link
Contributor

The default log level for geckodriver on release builds of Firefox is INFO level, which isn’t really that chatty. Perhaps your framework or language binding is overriding this.

You can override the logging level by passing {log: {level: LEVEL}} as part of the moz:firefoxProfile capability dictionary when starting a session. This is documented in the README.

@zhangshengni
Copy link

Hi @andreastt ,
I add these codes to set log level to error:

			FirefoxProfile firefoxProfile = new FirefoxProfile(new File("C:\\Users\\naomizhang\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\noz57ptq.default"));
			DesiredCapabilities capabilities = DesiredCapabilities.firefox();
			FirefoxOptions options = new FirefoxOptions();
			options.addPreference("--log", "error");
			//options.addPreference("--log-level", "error"); this line also doesn't work.
			capabilities.setCapability("moz:firefoxOptions", options);
			capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
			webDriver= new FirefoxDriver(capabilities);

But I still can get these logs on my console:

1481596567440	mozprofile::profile	INFO	Using profile path C:\Users\NAOMIZ~1\AppData\Local\Temp\rust_mozprofile.Vl2Hlgj2UEhQ
1481596567822	geckodriver::marionette	INFO	Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1481596567827	geckodriver::marionette	INFO	Connecting to Marionette on localhost:51813
1481596567975	addons.manager	DEBUG	Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1481596567977	addons.manager	DEBUG	Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]

I really don't want to see these logs any more, could you give me a favour to remove these logs(info and debug)?

my geckodriver version is v0.11.0. and my selenium version is 3.0.1.

Thank you!

@andreastt
Copy link
Contributor

options.addPreference("--log", "error") is setting a preference and not an option.

The log messages you see from geckodriver are INFO-level and expected. It doesn’t control the additional log level output from other components in Gecko, i.e. from the addons.manager. There is AFAIK no way of controlling that. If you want to discard it altogether you need to use something akin to geckodriver --log error >/dev/null on Unix.

@zhangshengni
Copy link

@andreastt
Thank you so much for your response. Since I'm using windows, I guess I have to wait for a new selenium or geckodriver.

@andreastt
Copy link
Contributor

Well I’m not sure what client binding you are using, but most bindings have a way to discard stdout from subprocesses. Certainly in the case of the Python bindings, all stdout is redirected to a file called geckodriver.log in your current working directory.

@komlevv
Copy link

komlevv commented Dec 24, 2016

@naomizhang4

you can send to dev/null with os module in python
webdriver.Firefox(firefox_profile=webdriver.FirefoxProfile(), log_path=os.devnull)
imo gecko log is too verbose still even at INFO level and there should be a clear way to disable it

@lintuxt
Copy link

lintuxt commented Jan 19, 2017

Hello guys, any updates on this? I've tried all suggested options above and none of them seems to work.

@andreastt
Copy link
Contributor

@lintuxt Make sure you are using the latest Firefox Nightly and set {"moz:firefoxOptions": {"logging": "level": "trace"}}} as a capability.

@ChpNick
Copy link

ChpNick commented Jan 24, 2017

How set {"moz:firefoxOptions": {"logging": "level": "trace"}}} as a capability ?

@jgraham
Copy link
Member

jgraham commented Jan 24, 2017

That depends on which client bindings you are using. Hopefully you can consult the documentation there to figure out how to set capabilities.

@ChpNick
Copy link

ChpNick commented Jan 24, 2017

Please write an example. I use the following construct:
DesiredCapabilities.firefox()
FirefoxDriver(capabilities)

@lintuxt
Copy link

lintuxt commented Jan 24, 2017

Could someone give me an example using Selenium with Java? Sincerely I don't understand the need to be so cryptic here. In Selenium with Java, I don't have a clear way to pass a JSON as a parameter anywhere.

@andreastt
Copy link
Contributor

@lintuxt @ChpNick Please consult the API for your respective language bindings. This is completely off topic for the geckodriver project.

Locking this issue.

@mozilla mozilla locked and limited conversation to collaborators Jan 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants