You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update Python logging examples in documentation. (#2206)[deploy site]
* Update Python logging examples in documentation.
This adds information to the logging docs in
`documentation/webdriver/troubleshooting/`` for setting up
log handlers in Python. This is necessary to get log output.
* Add file logging to Python logging examples
---------
Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com> e4f3470
Copy file name to clipboardExpand all lines: documentation/_print/index.html
+14-9Lines changed: 14 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -8765,7 +8765,12 @@
8765
8765
to look at the important Selenium logs,
8766
8766
take a look at the <a href=https://github.com/titusfortner/selenium-logger#selenium-logger>Selenium Logger project</a></p></div><div class="tab-body tab-pane fade" id=tabs-00-01 role=tabpanel aria-labelled-by=tabs-00-01-tab tabindex=0><p>Python logs are typically created per module. You can match all submodules by referencing the top
8767
8767
level module. So to work with all loggers in selenium module, you can do this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span> <span style=color:#000>logger</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>logging</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>getLogger</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>'selenium'</span><span style=color:#000;font-weight:700>)</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk//examples/python/tests/troubleshooting/test_logging.py#L5 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
8768
-
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-00-02 role=tabpanel aria-labelled-by=tabs-00-02-tab tabindex=0><p>.NET logger is managed with a static class, so all access to logging is managed simply by referencing <code>Log</code> from the <code>OpenQA.Selenium.Internal.Logging</code> namespace.</p></div><div class="tab-body tab-pane fade" id=tabs-00-03 role=tabpanel aria-labelled-by=tabs-00-03-tab tabindex=0><p>If you want to see as much debugging as possible in all the classes,
8768
+
<strong>View full example on GitHub</strong></a></div><p>You must also create and add a log handler (<code>StreamHandler</code>, <code>FileHandler</code>, etc).</p><p>To save logs to a file, you can do this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span><span style=color:#000>log_path</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>'/path/to/log'</span>
</span></span></code></pre></div><p>To display logs in the console, you can do this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span><span style=color:#000>handler</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>logging</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>StreamHandler</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div></div><div class="tab-body tab-pane fade" id=tabs-00-02 role=tabpanel aria-labelled-by=tabs-00-02-tab tabindex=0><p>.NET logger is managed with a static class, so all access to logging is managed simply by referencing <code>Log</code> from the <code>OpenQA.Selenium.Internal.Logging</code> namespace.</p></div><div class="tab-body tab-pane fade" id=tabs-00-03 role=tabpanel aria-labelled-by=tabs-00-03-tab tabindex=0><p>If you want to see as much debugging as possible in all the classes,
8769
8774
you can turn on debugging globally in Ruby by setting <code>$DEBUG = true</code>.</p><p>For more fine-tuned control, Ruby Selenium created its own Logger class to wrap the default <code>Logger</code> class.
8770
8775
This implementation provides some interesting additional features.
8771
8776
Obtain the logger directly from the <code>#logger</code>class method on the <code>Selenium::WebDriver</code> module:</p><p><a href=https://github.com/SeleniumHQ/selenium/releases/tag/selenium-4.10.0><span class=selenium-badge-version data-bs-toggle=tooltip data-bs-placement=right title="This code requires Selenium v4.10 or greater">Selenium v4.10</span></a></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-rb data-lang=rb><span style=display:flex><span> <span style=color:#000>logger</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>Selenium</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>WebDriver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>logger</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk//examples/ruby/spec/troubleshooting/logging_spec.rb#L11 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
@@ -13962,7 +13967,7 @@
13962
13967
No patent liability is assumed with respect
13963
13968
to the use of the information contained herein.</p><h2 id=attributions>Attributions</h2><h4 id=selenium-main-repositorygithubcomseleniumhqselenium><a href=//github.com/SeleniumHQ/selenium/>Selenium Main Repository</a></h4><style type=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>div label{padding-left:4px}.ghContributors>div span{font-size:x-small;padding-left:4px}</style><div class=ghContributors><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/28229?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
Copy file name to clipboardExpand all lines: documentation/about/_print/index.html
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@
41
41
No patent liability is assumed with respect
42
42
to the use of the information contained herein.</p><h2id=attributions>Attributions</h2><h4id=selenium-main-repositorygithubcomseleniumhqselenium><ahref=//github.com/SeleniumHQ/selenium/>Selenium Main Repository</a></h4><styletype=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>divlabel{padding-left:4px}.ghContributors>divspan{font-size:x-small;padding-left:4px}</style><divclass=ghContributors><divstyle=padding:10px><imgsrc="https://avatars.githubusercontent.com/u/28229?v=4" class=inlinewidth=100height=100style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
0 commit comments