|
1 | 1 | ---
|
2 |
| -title: "Logging Selenium commands" |
3 |
| -linkTitle: "Logging" |
| 2 | +title: "记录 Selenium 命令" |
| 3 | +linkTitle: "日志" |
4 | 4 | weight: 4
|
5 | 5 | description: >
|
6 |
| - Getting information about Selenium execution. |
| 6 | + 获取Selenium的执行信息. |
7 | 7 | ---
|
8 | 8 |
|
9 |
| -Turning on logging is a valuable way to get extra information that might help you determine |
10 |
| -why you might be having a problem. |
| 9 | +启用日志记录是获取额外信息的宝贵方法, |
| 10 | +这些信息可能有助于您确定 |
| 11 | +遇到问题的原因. |
11 | 12 |
|
12 |
| -## Getting a logger |
| 13 | +## 获取一个logger |
13 | 14 |
|
14 | 15 | {{< tabpane langEqualsHeader=true text=true >}}
|
15 | 16 | {{% tab header="Java" %}}
|
16 |
| -Java logs are typically created per class. You can work with the default logger to |
17 |
| -work with all loggers. To filter out specific classes, see [Filtering](#logger-filtering) |
| 17 | +Java 日志通常是按类创建的. |
| 18 | +您可以通过默认logger来使用所有loggers. |
| 19 | +为了过滤特定类, 请参考 [过滤器](#logger-过滤) |
18 | 20 |
|
19 |
| -Get the root logger: |
| 21 | +获取根logger: |
20 | 22 | {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/troubleshooting/LoggingTest.java#L31" >}}
|
21 | 23 |
|
22 |
| -Java Logging is not exactly straightforward, and if you are just looking for an easy way |
23 |
| -to look at the important Selenium logs, |
24 |
| -take a look at the [Selenium Logger project](https://github.com/titusfortner/selenium-logger#selenium-logger) |
| 24 | +Java日志并不简单直接, |
| 25 | +如果您只是在寻找一种简单的方法 |
| 26 | +查看重要的Selenium日志, |
| 27 | +请参阅 [Selenium Logger 项目](https://github.com/titusfortner/selenium-logger#selenium-logger) |
25 | 28 | {{% /tab %}}
|
26 | 29 | {{% tab header="Python" %}}
|
27 | 30 | Python logs are typically created per module. You can match all submodules by referencing the top
|
@@ -54,15 +57,15 @@ logger = logging.getLogger('webdriver')
|
54 | 57 | {{< /tab >}}
|
55 | 58 | {{< /tabpane >}}
|
56 | 59 |
|
57 |
| -## Logger level |
58 |
| -Logger level helps to filter out logs based on their severity. |
| 60 | +## 日志级别 |
| 61 | +Logger级别有助于根据日志的严重性过滤日志. |
59 | 62 |
|
60 | 63 | {{< tabpane langEqualsHeader=true text=true >}}
|
61 | 64 | {{% tab header="Java" %}}
|
62 |
| - Java has 7 logger levels: `SEVERE`, `WARNING`, `INFO`, `CONFIG`, `FINE`, `FINER`, and `FINEST`. |
63 |
| -The default is `INFO`. |
| 65 | + Java有七种logger级别: `SEVERE`, `WARNING`, `INFO`, `CONFIG`, `FINE`, `FINER`, 以及 `FINEST`. |
| 66 | +默认是 `INFO`. |
64 | 67 |
|
65 |
| -You have to change both the level of the logger and the level of the handlers on the root logger: |
| 68 | +您必须更改logger的级别和根logger上的处理程序的级别: |
66 | 69 | {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/troubleshooting/LoggingTest.java#L32-L35" >}}
|
67 | 70 | {{% /tab %}}
|
68 | 71 | {{% tab header="Python" %}}
|
@@ -120,14 +123,15 @@ logger.setLevel(logging.Level.INFO)
|
120 | 123 |
|
121 | 124 | ### Actionable items
|
122 | 125 |
|
123 |
| -Things are logged as warnings if they are something the user needs to take action on. This is often used |
124 |
| -for deprecations. For various reasons, Selenium project does not follow standard Semantic Versioning practices. |
125 |
| -Our policy is to mark things as deprecated for 3 releases and then remove them, so deprecations |
126 |
| -may be logged as warnings. |
| 126 | +对于需要用户后续行动的操作, 会将其记录为警告. |
| 127 | +这经常用于被弃用的内容. |
| 128 | +由于各种原因, Selenium项目不遵循标准的语义版本控制实践. |
| 129 | +我们的政策是将 3 个版本的内容标记为已弃用后, |
| 130 | +再删除它们, 因此弃用可能记录为警告. |
127 | 131 |
|
128 | 132 | {{< tabpane langEqualsHeader=true text=true >}}
|
129 | 133 | {{% tab header="Java" %}}
|
130 |
| -Java logs actionable content at logger level `WARN` |
| 134 | +Java 日志可操作的内容在logger级别 `WARN` |
131 | 135 |
|
132 | 136 | Example:
|
133 | 137 | ```text
|
@@ -169,12 +173,12 @@ For example:
|
169 | 173 |
|
170 | 174 | ### Useful information
|
171 | 175 |
|
172 |
| -This is the default level where Selenium logs things that users should be aware of but do not need to take actions on. |
173 |
| -This might reference a new method or direct users to more information about something |
| 176 | +这是默认级别, Selenium 记录用户应该注意但不需要对其执行操作的内容. |
| 177 | +这可能会引用新方法或将用户定向到有关某些内容的详细信息 |
174 | 178 |
|
175 | 179 | {{< tabpane langEqualsHeader=true text=true >}}
|
176 | 180 | {{% tab header="Java" %}}
|
177 |
| - Java logs useful information at logger level `INFO` |
| 181 | + Java 日志有用的信息在logger 级别 `INFO` |
178 | 182 |
|
179 | 183 | Example:
|
180 | 184 | ```text
|
@@ -214,11 +218,11 @@ Example:
|
214 | 218 |
|
215 | 219 | ### Debugging Details
|
216 | 220 |
|
217 |
| -The debug log level is used for information that may be needed for diagnosing issues and troubleshooting problems. |
| 221 | +调试日志级别用于诊断问题和解决问题可能需要的信息. |
218 | 222 |
|
219 | 223 | {{< tabpane langEqualsHeader=true text=true >}}
|
220 | 224 | {{% tab header="Java" %}}
|
221 |
| -Java logs most debug content at logger level `FINE` |
| 225 | +Java日志的大多数调试信息在logger 级别 `FINE` |
222 | 226 |
|
223 | 227 | Example:
|
224 | 228 | ```text
|
@@ -255,13 +259,15 @@ Example:
|
255 | 259 | {{< /tab >}}
|
256 | 260 | {{< /tabpane >}}
|
257 | 261 |
|
258 |
| -## Logger output |
| 262 | +## Logger 输出 |
259 | 263 |
|
260 |
| -Logs can be displayed in the console or stored in a file. Different languages have different defaults. |
| 264 | +日志可以显示在控制台中, 也可以存储在文件中. |
| 265 | +不同的语言有不同的默认值. |
261 | 266 |
|
262 | 267 | {{< tabpane langEqualsHeader=true text=true >}}
|
263 | 268 | {{% tab header="Java" %}}
|
264 |
| -By default all logs are sent to `System.err`. To direct output to a file, you need to add a handler: |
| 269 | +默认情况下, 所有日志都发送到 `System.err`. |
| 270 | +要将输出定向到文件, 您需要添加一个处理程序: |
265 | 271 |
|
266 | 272 | {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/troubleshooting/LoggingTest.java#L37-L38" >}}
|
267 | 273 | {{% /tab %}}
|
@@ -294,13 +300,14 @@ logging.installConsoleHandler()
|
294 | 300 | {{< /tab >}}
|
295 | 301 | {{< /tabpane >}}
|
296 | 302 |
|
297 |
| -## Logger filtering |
| 303 | +## Logger 过滤 |
298 | 304 |
|
299 | 305 | {{< tabpane langEqualsHeader=true text=true >}}
|
300 | 306 | {{% tab header="Java" %}}
|
301 |
| -Java logging is managed on a per class level, so |
302 |
| -instead of using the root logger (`Logger.getLogger("")`), set the level you want to use on a per-class |
303 |
| -basis: |
| 307 | +Java 日志记录是按类级别管理的, |
| 308 | +因此不要使用根logger (`Logger.getLogger("")`), |
| 309 | +而是在每个类的基础上设置要使用的级别: |
| 310 | + |
304 | 311 | {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/troubleshooting/LoggingTest.java#L40-L41" >}}
|
305 | 312 | {{% /tab %}}
|
306 | 313 | {{< tab header="Python" >}}
|
|
0 commit comments