Skip to content

Commit 31547d7

Browse files
committed
Add file logging to Python logging examples
1 parent 6eca61c commit 31547d7

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

website_and_docs/content/documentation/webdriver/troubleshooting/logging.en.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ 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 set a handler (`StreamHandler`, `FileHandler('/path/to/log')`, etc).
31-
For example, to see logs in the console, you can do this:
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:
3240
```py
3341
handler = logging.StreamHandler()
3442
logger.addHandler(handler)

website_and_docs/content/documentation/webdriver/troubleshooting/logging.ja.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ 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 set a handler (`StreamHandler`, `FileHandler('/path/to/log')`, etc).
31-
For example, to see logs in the console, you can do this:
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:
3240
```py
3341
handler = logging.StreamHandler()
3442
logger.addHandler(handler)

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ 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 set a handler (`StreamHandler`, `FileHandler('/path/to/log')`, etc).
31-
For example, to see logs in the console, you can do this:
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:
3240
```py
3341
handler = logging.StreamHandler()
3442
logger.addHandler(handler)

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@ 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 set a handler (`StreamHandler`, `FileHandler('/path/to/log')`, etc).
34-
For example, to see logs in the console, you can do this:
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:
3543
```py
3644
handler = logging.StreamHandler()
3745
logger.addHandler(handler)

0 commit comments

Comments
 (0)