Skip to content

Commit e4f3470

Browse files
cgoldbergharsha509
andauthored
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 <[email protected]>
1 parent 1b5e20e commit e4f3470

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

Diff for: website_and_docs/content/documentation/webdriver/troubleshooting/logging.en.md

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ take a look at the [Selenium Logger project](https://github.com/titusfortner/sel
2727
Python logs are typically created per module. You can match all submodules by referencing the top
2828
level module. So to work with all loggers in selenium module, you can do this:
2929
{{< gh-codeblock path="/examples/python/tests/troubleshooting/test_logging.py#L5" >}}
30+
You must also create and add a log handler (`StreamHandler`, `FileHandler`, etc).
31+
32+
To save logs to a file, you can do this:
33+
```py
34+
log_path = '/path/to/log'
35+
handler = logging.FileHandler(log_path)
36+
logger.addHandler(handler)
37+
```
38+
39+
To display logs in the console, you can do this:
40+
```py
41+
handler = logging.StreamHandler()
42+
logger.addHandler(handler)
43+
```
3044
{{% /tab %}}
3145
{{% tab header="CSharp" %}}
3246
.NET logger is managed with a static class, so all access to logging is managed simply by referencing `Log` from the `OpenQA.Selenium.Internal.Logging` namespace.

Diff for: website_and_docs/content/documentation/webdriver/troubleshooting/logging.ja.md

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ take a look at the [Selenium Logger project](https://github.com/titusfortner/sel
2727
Python logs are typically created per module. You can match all submodules by referencing the top
2828
level module. So to work with all loggers in selenium module, you can do this:
2929
{{< gh-codeblock path="/examples/python/tests/troubleshooting/test_logging.py#L5" >}}
30+
You must also create and add a log handler (`StreamHandler`, `FileHandler`, etc).
31+
32+
To save logs to a file, you can do this:
33+
```py
34+
log_path = '/path/to/log'
35+
handler = logging.FileHandler(log_path)
36+
logger.addHandler(handler)
37+
```
38+
39+
To display logs in the console, you can do this:
40+
```py
41+
handler = logging.StreamHandler()
42+
logger.addHandler(handler)
43+
```
3044
{{% /tab %}}
3145
{{% tab header="CSharp" %}}
3246
.NET logger is managed with a static class, so all access to logging is managed simply by referencing `Log` from the `OpenQA.Selenium.Internal.Logging` namespace.

Diff for: website_and_docs/content/documentation/webdriver/troubleshooting/logging.pt-br.md

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ take a look at the [Selenium Logger project](https://github.com/titusfortner/sel
2727
Python logs are typically created per module. You can match all submodules by referencing the top
2828
level module. So to work with all loggers in selenium module, you can do this:
2929
{{< gh-codeblock path="/examples/python/tests/troubleshooting/test_logging.py#L5" >}}
30+
You must also create and add a log handler (`StreamHandler`, `FileHandler`, etc).
31+
32+
To save logs to a file, you can do this:
33+
```py
34+
log_path = '/path/to/log'
35+
handler = logging.FileHandler(log_path)
36+
logger.addHandler(handler)
37+
```
38+
39+
To display logs in the console, you can do this:
40+
```py
41+
handler = logging.StreamHandler()
42+
logger.addHandler(handler)
43+
```
3044
{{% /tab %}}
3145
{{% tab header="CSharp" %}}
3246
.NET logger is managed with a static class, so all access to logging is managed simply by referencing `Log` from the `OpenQA.Selenium.Internal.Logging` namespace.

Diff for: website_and_docs/content/documentation/webdriver/troubleshooting/logging.zh-cn.md

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ Java日志并不简单直接,
3030
Python logs are typically created per module. You can match all submodules by referencing the top
3131
level module. So to work with all loggers in selenium module, you can do this:
3232
{{< gh-codeblock path="/examples/python/tests/troubleshooting/test_logging.py#L5" >}}
33+
You must also create and add a log handler (`StreamHandler`, `FileHandler`, etc).
34+
35+
To save logs to a file, you can do this:
36+
```py
37+
log_path = '/path/to/log'
38+
handler = logging.FileHandler(log_path)
39+
logger.addHandler(handler)
40+
```
41+
42+
To display logs in the console, you can do this:
43+
```py
44+
handler = logging.StreamHandler()
45+
logger.addHandler(handler)
46+
```
3347
{{% /tab %}}
3448
{{% tab header="CSharp" %}}
3549
.NET logger is managed with a static class, so all access to logging is managed simply by referencing `Log` from the `OpenQA.Selenium.Internal.Logging` namespace.

0 commit comments

Comments
 (0)