- Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathlogging.po
1653 lines (1435 loc) · 83.1 KB
/
logging.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2024, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Rafael Fontenelle <rffontenelle@gmail.com>, 2024
# Freesand Leo <yuqinju@163.com>, 2024
#
#,fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-20 15:27+0000\n"
"PO-Revision-Date: 2023-05-24 02:11+0000\n"
"Last-Translator: Freesand Leo <yuqinju@163.com>, 2024\n"
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#:../../howto/logging.rst:3
msgid"Logging HOWTO"
msgstr"日志指南"
#:../../howto/logging.rst:0
msgid"Author"
msgstr"作者"
#:../../howto/logging.rst:5
msgid"Vinay Sajip <vinay_sajip at red-dove dot com>"
msgstr"Vinay Sajip <vinay_sajip at red-dove dot com>"
#:../../howto/logging.rst:12
msgid"Basic Logging Tutorial"
msgstr"日志基础教程"
#:../../howto/logging.rst:14
msgid""
"Logging is a means of tracking events that happen when some software runs. "
"The software's developer adds logging calls to their code to indicate that "
"certain events have occurred. An event is described by a descriptive message"
" which can optionally contain variable data (i.e. data that is potentially "
"different for each occurrence of the event). Events also have an importance "
"which the developer ascribes to the event; the importance can also be called"
" the *level* or *severity*."
msgstr""
"日志是对软件执行时所发生事件的一种追踪方式。软件开发人员对他们的代码添加日志调用,借此来指示某事件的发生。一个事件通过一些包含变量数据的描述信息来描述(比如:每个事件发生时的数据都是不同的)。开发者还会区分事件的重要性,重要性也被称为"
" *等级* 或 *严重性*。"
#:../../howto/logging.rst:23
msgid"When to use logging"
msgstr"什么时候使用日志"
#:../../howto/logging.rst:25
msgid""
"You can access logging functionality by creating a logger via ``logger = "
"getLogger(__name__)``, and then calling the logger's :meth:`~Logger.debug`, "
":meth:`~Logger.info`, :meth:`~Logger.warning`, :meth:`~Logger.error` and "
":meth:`~Logger.critical` methods. To determine when to use logging, and to "
"see which logger methods to use when, see the table below. It states, for "
"each of a set of common tasks, the best tool to use for that task."
msgstr""
"你可以通过执行 ``logger = getLogger(__name__)`` 创建一个日志记录器然后调用日志记录器的 "
":meth:`~Logger.debug`, :meth:`~Logger.info`, :meth:`~Logger.warning`, "
":meth:`~Logger.error` 和 :meth:`~Logger.critical` 方法来使用日志记录功能。 "
"要确定何时使用日志记录,以及确定要使用哪个日志记录器方法,请参阅下表。 它针对一组常见任务中的每一个都列出了最适合该任务的工具。"
#:../../howto/logging.rst:33
msgid"Task you want to perform"
msgstr"你想要执行的任务"
#:../../howto/logging.rst:33
msgid"The best tool for the task"
msgstr"此任务最好的工具"
#:../../howto/logging.rst:35
msgid""
"Display console output for ordinary usage of a command line script or "
"program"
msgstr"对于命令行或程序的应用,结果显示在控制台。"
#:../../howto/logging.rst:35
msgid":func:`print`"
msgstr":func:`print`"
#:../../howto/logging.rst:39
msgid""
"Report events that occur during normal operation of a program (e.g. for "
"status monitoring or fault investigation)"
msgstr"在对程序的普通操作发生时提交事件报告(比如:状态监控和错误调查)"
#:../../howto/logging.rst:39
msgid""
"A logger's :meth:`~Logger.info` (or :meth:`~Logger.debug` method for very "
"detailed output for diagnostic purposes)"
msgstr""
"日志记录器的 :meth:`~Logger.info` (或者对于诊断目的需要非常详细的输出时则使用 :meth:`~Logger.debug` 方法)"
#:../../howto/logging.rst:44
msgid"Issue a warning regarding a particular runtime event"
msgstr"提出一个警告信息基于一个特殊的运行时事件"
#:../../howto/logging.rst:44
msgid""
":func:`warnings.warn` in library code if the issue is avoidable and the "
"client application should be modified to eliminate the warning"
msgstr":func:`warnings.warn` 位于代码库中,该事件是可以避免的,需要修改客户端应用以消除告警"
#:../../howto/logging.rst:49
msgid""
"A logger's :meth:`~Logger.warning` method if there is nothing the client "
"application can do about the situation, but the event should still be noted"
msgstr"对于客户端应用无法干预,但事件仍然需要被关注的场合则使用日志记录器的 :meth:`~Logger.warning` 方法"
#:../../howto/logging.rst:55
msgid"Report an error regarding a particular runtime event"
msgstr"对一个特殊的运行时事件报告错误"
#:../../howto/logging.rst:55
msgid"Raise an exception"
msgstr"引发异常"
#:../../howto/logging.rst:58
msgid""
"Report suppression of an error without raising an exception (e.g. error "
"handler in a long-running server process)"
msgstr"报告错误而不引发异常(如在长时间运行中的服务端进程的错误处理)"
#:../../howto/logging.rst:58
msgid""
"A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` or "
":meth:`~Logger.critical` method as appropriate for the specific error and "
"application domain"
msgstr""
"日志记录器的 :meth:`~Logger.error`, :meth:`~Logger.exception` 或 "
":meth:`~Logger.critical` 方法分别适用于特定的错误及应用领域"
#:../../howto/logging.rst:65
msgid""
"The logger methods are named after the level or severity of the events they "
"are used to track. The standard levels and their applicability are described"
" below (in increasing order of severity):"
msgstr"日志记录器方法以它们所追踪的事件级别或严重程度来命名。 标准的级别及其适用性如下所述(严重程序从低至高):"
#:../../howto/logging.rst:72../../howto/logging.rst:827
msgid"Level"
msgstr"级别"
#:../../howto/logging.rst:72
msgid"When it's used"
msgstr"何时使用"
#:../../howto/logging.rst:74../../howto/logging.rst:837
msgid"``DEBUG``"
msgstr"``DEBUG``"
#:../../howto/logging.rst:74
msgid""
"Detailed information, typically of interest only when diagnosing problems."
msgstr"细节信息,仅当诊断问题时适用。"
#:../../howto/logging.rst:77../../howto/logging.rst:835
msgid"``INFO``"
msgstr"``INFO``"
#:../../howto/logging.rst:77
msgid"Confirmation that things are working as expected."
msgstr"确认程序按预期运行。"
#:../../howto/logging.rst:80../../howto/logging.rst:833
msgid"``WARNING``"
msgstr"``WARNING``"
#:../../howto/logging.rst:80
msgid""
"An indication that something unexpected happened, or indicative of some "
"problem in the near future (e.g. 'disk space low'). The software is still "
"working as expected."
msgstr"表明有已经或即将发生的意外(例如:磁盘空间不足)。程序仍按预期进行。"
#:../../howto/logging.rst:85../../howto/logging.rst:831
msgid"``ERROR``"
msgstr"``ERROR``"
#:../../howto/logging.rst:85
msgid""
"Due to a more serious problem, the software has not been able to perform "
"some function."
msgstr"由于严重的问题,程序的某些功能已经不能正常执行"
#:../../howto/logging.rst:88../../howto/logging.rst:829
msgid"``CRITICAL``"
msgstr"``CRITICAL``"
#:../../howto/logging.rst:88
msgid""
"A serious error, indicating that the program itself may be unable to "
"continue running."
msgstr"严重的错误,表明程序已不能继续执行"
#:../../howto/logging.rst:92
msgid""
"The default level is ``WARNING``, which means that only events of this level"
" and above will be tracked, unless the logging package is configured to do "
"otherwise."
msgstr"默认的级别是 ``WARNING``,意味着只会追踪该级别及以上的事件,除非更改日志配置。"
#:../../howto/logging.rst:96
msgid""
"Events that are tracked can be handled in different ways. The simplest way "
"of handling tracked events is to print them to the console. Another common "
"way is to write them to a disk file."
msgstr"所追踪事件可以以不同形式处理。最简单的方式是输出到控制台。另一种常用的方式是写入磁盘文件。"
#:../../howto/logging.rst:104
msgid"A simple example"
msgstr"一个简单的例子"
#:../../howto/logging.rst:106
msgid"A very simple example is::"
msgstr"一个非常简单的例子::"
#:../../howto/logging.rst:112
msgid"If you type these lines into a script and run it, you'll see:"
msgstr"如果你在命令行中输入这些代码并运行,你将会看到:"
#:../../howto/logging.rst:118
msgid""
"printed out on the console. The ``INFO`` message doesn't appear because the "
"default level is ``WARNING``. The printed message includes the indication of"
" the level and the description of the event provided in the logging call, "
"i.e. 'Watch out!'. The actual output can be formatted quite flexibly if you "
"need that; formatting options will also be explained later."
msgstr""
"在控制台上打印出来。 ``INFO`` 消息没有出现是因为默认级别为 ``WARNING``。 "
"打印的消息包括在日志记录调用中提供的事件级别和描述信息,例如 'Watch out!'。 "
"实际输出可以按你的需要相当灵活地格式化;格式化选项也将在后文中进行说明。"
#:../../howto/logging.rst:124
msgid""
"Notice that in this example, we use functions directly on the ``logging`` "
"module, like ``logging.debug``, rather than creating a logger and calling "
"functions on it. These functions operation on the root logger, but can be "
"useful as they will call :func:`~logging.basicConfig` for you if it has not "
"been called yet, like in this example. In larger programs you'll usually "
"want to control the logging configuration explicitly however - so for that "
"reason as well as others, it's better to create loggers and call their "
"methods."
msgstr""
"请注意在这个例子中,我们是直接使用 ``logging`` 模块的函数,比如 ``logging.debug``,而不是创建一个日志记录器并调用其方法。"
" 这些函数是在根日志记录器上操作的,但它们在未被调用时将会调用 :func:`~logging.basicConfig` "
"来发挥作用,就像在这个例子中那样。 然而在更大的程序中你通常会需要显式地控制日志记录的配置 —— "
"所以出于这样那样的理由,最好还是创建日志记录器并调用其方法。"
#:../../howto/logging.rst:133
msgid"Logging to a file"
msgstr"记录日志到文件"
#:../../howto/logging.rst:135
msgid""
"A very common situation is that of recording logging events in a file, so "
"let's look at that next. Be sure to try the following in a newly started "
"Python interpreter, and don't just continue from the session described "
"above::"
msgstr""
"一种很常见的情况是将日志事件记录到文件中,下面让我们来看这个问题。 请确认在一个新启动的 Python "
"解释器中尝试以下操作,而非在上面描述的会话中继续::"
#:../../howto/logging.rst:147
msgid""
"The *encoding* argument was added. In earlier Python versions, or if not "
"specified, the encoding used is the default value used by :func:`open`. "
"While not shown in the above example, an *errors* argument can also now be "
"passed, which determines how encoding errors are handled. For available "
"values and the default, see the documentation for :func:`open`."
msgstr""
"增加了 *encoding* 参数。在更早的 Python 版本中或没有指定时,编码会用 :func:`open` "
"使用的默认值。尽管在上面的例子中没有展示,但也可以传入一个决定如何处理编码错误的 *errors* 参数。可使用的值和默认值,请参照 "
":func:`open` 的文档。"
#:../../howto/logging.rst:154
msgid""
"And now if we open the file and look at what we have, we should find the log"
" messages:"
msgstr"现在,如果我们打开日志文件,我们应当能看到日志信息:"
#:../../howto/logging.rst:164
msgid""
"This example also shows how you can set the logging level which acts as the "
"threshold for tracking. In this case, because we set the threshold to "
"``DEBUG``, all of the messages were printed."
msgstr"该示例同样展示了如何设置日志追踪级别的阈值。该示例中,由于我们设置的阈值是 ``DEBUG``,所有信息都将被打印。"
#:../../howto/logging.rst:168
msgid""
"If you want to set the logging level from a command-line option such as:"
msgstr"如果你想从命令行设置日志级别,例如:"
#:../../howto/logging.rst:174
msgid""
"and you have the value of the parameter passed for ``--log`` in some "
"variable *loglevel*, you can use::"
msgstr"并且你将 ``--log`` 命令的参数存进了变量 *loglevel*,你可以用:"
#:../../howto/logging.rst:179
msgid""
"to get the value which you'll pass to :func:`basicConfig` via the *level* "
"argument. You may want to error check any user input value, perhaps as in "
"the following example::"
msgstr"获取要通过 *level* 参数传给 :func:`basicConfig` 的值。可如下对用户输入值进行错误检查:"
#:../../howto/logging.rst:191
msgid""
"The call to :func:`basicConfig` should come *before* any calls to a logger's"
" methods such as :meth:`~Logger.debug`, :meth:`~Logger.info`, etc. "
"Otherwise, that logging event may not be handled in the desired manner."
msgstr""
"对 :func:`basicConfig` 的调用应当在任何对日志记录器方法的调用如 :meth:`~Logger.debug`, "
":meth:`~Logger.info` 等 *之前* 执行。 否则,日志记录事件可能无法以预期的方式来处理。"
#:../../howto/logging.rst:195
msgid""
"If you run the above script several times, the messages from successive runs"
" are appended to the file *example.log*. If you want each run to start "
"afresh, not remembering the messages from earlier runs, you can specify the "
"*filemode* argument, by changing the call in the above example to::"
msgstr""
"如果多次运行上述脚本,则连续运行的消息将追加到文件 *example.log* 。 "
"如果你希望每次运行重新开始,而不是记住先前运行的消息,则可以通过将上例中的调用更改为来指定 *filemode* 参数::"
#:../../howto/logging.rst:202
msgid""
"The output will be the same as before, but the log file is no longer "
"appended to, so the messages from earlier runs are lost."
msgstr"输出将与之前相同,但不再追加进日志文件,因此早期运行的消息将丢失。"
#:../../howto/logging.rst:207
msgid"Logging variable data"
msgstr"记录变量数据"
#:../../howto/logging.rst:209
msgid""
"To log variable data, use a format string for the event description message "
"and append the variable data as arguments. For example::"
msgstr"要记录变量数据,请使用格式字符串作为事件描述消息,并附加传入变量数据作为参数。 例如::"
#:../../howto/logging.rst:215
msgid"will display:"
msgstr"将显示:"
#:../../howto/logging.rst:221
msgid""
"As you can see, merging of variable data into the event description message "
"uses the old, %-style of string formatting. This is for backwards "
"compatibility: the logging package pre-dates newer formatting options such "
"as :meth:`str.format` and :class:`string.Template`. These newer formatting "
"options *are* supported, but exploring them is outside the scope of this "
"tutorial: see :ref:`formatting-styles` for more information."
msgstr""
"如你所见,将可变数据合并到事件描述消息中使用旧的 %-s形式的字符串格式化。 这是为了向后兼容:logging 包的出现时间早于较新的格式化选项例如 "
":meth:`str.format` 和 :class:`string.Template`。 这些较新格式化选项 *是* "
"受支持的,但探索它们超出了本教程的范围:有关详细信息,请参阅 :ref:`formatting-styles`。"
#:../../howto/logging.rst:230
msgid"Changing the format of displayed messages"
msgstr"更改显示消息的格式"
#:../../howto/logging.rst:232
msgid""
"To change the format which is used to display messages, you need to specify "
"the format you want to use::"
msgstr"要更改用于显示消息的格式,你需要指定要使用的格式::"
#:../../howto/logging.rst:241
msgid"which would print:"
msgstr"这将输出:"
#:../../howto/logging.rst:249
msgid""
"Notice that the 'root' which appeared in earlier examples has disappeared. "
"For a full set of things that can appear in format strings, you can refer to"
" the documentation for :ref:`logrecord-attributes`, but for simple usage, "
"you just need the *levelname* (severity), *message* (event description, "
"including variable data) and perhaps to display when the event occurred. "
"This is described in the next section."
msgstr""
"注意在前面例子中出现的 “root” 已消失。文档 :ref:`logrecord-attributes` "
"列出了可在格式字符串中出现的所有内容,但在简单的使用场景中,你只需要 *levelname* (严重性)、*message* "
"(事件描述,包含可变的数据)或许再加上事件发生的时间。 这将在下一节中介绍。"
#:../../howto/logging.rst:258
msgid"Displaying the date/time in messages"
msgstr"在消息中显示日期/时间"
#:../../howto/logging.rst:260
msgid""
"To display the date and time of an event, you would place '%(asctime)s' in "
"your format string::"
msgstr"要显示事件的日期和时间,你可以在格式字符串中放置 '%(asctime)s' ::"
#:../../howto/logging.rst:267
msgid"which should print something like this:"
msgstr"应该打印这样的东西:"
#:../../howto/logging.rst:273
msgid""
"The default format for date/time display (shown above) is like ISO8601 or "
":rfc:`3339`. If you need more control over the formatting of the date/time, "
"provide a *datefmt* argument to ``basicConfig``, as in this example::"
msgstr""
"日期/时间显示的默认格式(如上所示)类似于 ISO8601 或 :rfc:`3339` 。 如果你需要更多地控制日期/时间的格式,请为 "
"``basicConfig`` 提供 *datefmt* 参数,如下例所示::"
#:../../howto/logging.rst:281
msgid"which would display something like this:"
msgstr"这会显示如下内容:"
#:../../howto/logging.rst:287
msgid""
"The format of the *datefmt* argument is the same as supported by "
":func:`time.strftime`."
msgstr"*datefmt* 参数的格式与 :func:`time.strftime` 支持的格式相同。"
#:../../howto/logging.rst:292
msgid"Next Steps"
msgstr"后续步骤"
#:../../howto/logging.rst:294
msgid""
"That concludes the basic tutorial. It should be enough to get you up and "
"running with logging. There's a lot more that the logging package offers, "
"but to get the best out of it, you'll need to invest a little more of your "
"time in reading the following sections. If you're ready for that, grab some "
"of your favourite beverage and carry on."
msgstr""
"基本教程到此结束。 它应该足以让你启动并运行日志记录。 logging 包提供了更多功能,但为了充分利用它,你需要花更多的时间来阅读以下部分。 "
"如果你准备好了,可以拿一些你最喜欢的饮料然后继续。"
#:../../howto/logging.rst:300
msgid""
"If your logging needs are simple, then use the above examples to incorporate"
" logging into your own scripts, and if you run into problems or don't "
"understand something, please post a question on the comp.lang.python Usenet "
"group (available at https://groups.google.com/g/comp.lang.python) and you "
"should receive help before too long."
msgstr""
"如果你的日志记录需要很简单,那就使用上述的示例将日志记录整合到你自己的脚本中,如果你遇到问题或有不理解的地方,请在 comp.lang.python "
"Usenet 群组发帖提问(访问 https://groups.google.com/g/comp.lang.python "
"即可),你应该能在不久之后获得帮助。"
#:../../howto/logging.rst:306
msgid""
"Still here? You can carry on reading the next few sections, which provide a "
"slightly more advanced/in-depth tutorial than the basic one above. After "
"that, you can take a look at the :ref:`logging-cookbook`."
msgstr""
"还不够? 你可以继续阅读接下来的几个部分,这些部分提供了比上面基本部分更高级或深入的教程。 之后,你可以看一下 :ref:`logging-"
"cookbook` 。"
#:../../howto/logging.rst:314
msgid"Advanced Logging Tutorial"
msgstr"进阶日志教程"
#:../../howto/logging.rst:316
msgid""
"The logging library takes a modular approach and offers several categories "
"of components: loggers, handlers, filters, and formatters."
msgstr"日志库采用模块化方法,并提供几类组件:记录器、处理器、过滤器和格式器。"
#:../../howto/logging.rst:319
msgid"Loggers expose the interface that application code directly uses."
msgstr"记录器暴露了应用程序代码直接使用的接口。"
#:../../howto/logging.rst:320
msgid""
"Handlers send the log records (created by loggers) to the appropriate "
"destination."
msgstr"处理器将日志记录(由记录器创建)发送到适当的目标。"
#:../../howto/logging.rst:322
msgid""
"Filters provide a finer grained facility for determining which log records "
"to output."
msgstr"过滤器提供了更细粒度的功能,用于确定要输出的日志记录。"
#:../../howto/logging.rst:324
msgid"Formatters specify the layout of log records in the final output."
msgstr"格式器指定最终输出中日志记录的样式。"
#:../../howto/logging.rst:326
msgid""
"Log event information is passed between loggers, handlers, filters and "
"formatters in a :class:`LogRecord` instance."
msgstr"日志事件信息在 :class:`LogRecord` 实例中的记录器、处理器、过滤器和格式器之间传递。"
#:../../howto/logging.rst:329
msgid""
"Logging is performed by calling methods on instances of the :class:`Logger` "
"class (hereafter called :dfn:`loggers`). Each instance has a name, and they "
"are conceptually arranged in a namespace hierarchy using dots (periods) as "
"separators. For example, a logger named 'scan' is the parent of loggers "
"'scan.text', 'scan.html' and 'scan.pdf'. Logger names can be anything you "
"want, and indicate the area of an application in which a logged message "
"originates."
msgstr""
"通过调用 :class:`Logger` 类(以下称为 :dfn:`loggers` , 记录器)的实例来执行日志记录。 "
"每个实例都有一个名称,它们在概念上以点(句点)作为分隔符排列在命名空间的层次结构中。 例如,名为 'scan' 的记录器是记录器 'scan.text'"
" ,'scan.html' 和 'scan.pdf' 的父级。 记录器名称可以是你想要的任何名称,并指示记录消息源自的应用程序区域。"
#:../../howto/logging.rst:336
msgid""
"A good convention to use when naming loggers is to use a module-level "
"logger, in each module which uses logging, named as follows::"
msgstr"在命名记录器时使用的一个好习惯是在每个使用日志记录的模块中使用模块级记录器,命名如下::"
#:../../howto/logging.rst:341
msgid""
"This means that logger names track the package/module hierarchy, and it's "
"intuitively obvious where events are logged just from the logger name."
msgstr"这意味着记录器名称跟踪包或模块的层次结构,并且直观地从记录器名称显示记录事件的位置。"
#:../../howto/logging.rst:344
msgid""
"The root of the hierarchy of loggers is called the root logger. That's the "
"logger used by the functions :func:`debug`, :func:`info`, :func:`warning`, "
":func:`error` and :func:`critical`, which just call the same-named method of"
" the root logger. The functions and the methods have the same signatures. "
"The root logger's name is printed as 'root' in the logged output."
msgstr""
"记录器层次结构的根称为根记录器。 这是函数 :func:`debug` 、 :func:`info` 、 :func:`warning` 、 "
":func:`error` 和 :func:`critical` 使用的记录器,它们就是调用了根记录器的同名方法。 函数和方法具有相同的签名。 "
"根记录器的名称在输出中打印为 'root' 。"
#:../../howto/logging.rst:350
msgid""
"It is, of course, possible to log messages to different destinations. "
"Support is included in the package for writing log messages to files, HTTP "
"GET/POST locations, email via SMTP, generic sockets, queues, or OS-specific "
"logging mechanisms such as syslog or the Windows NT event log. Destinations "
"are served by :dfn:`handler` classes. You can create your own log "
"destination class if you have special requirements not met by any of the "
"built-in handler classes."
msgstr""
"当然,可以将消息记录到不同的地方。 软件包中的支持包含,用于将日志消息写入文件、 HTTP GET/POST 位置、通过 SMTP "
"发送电子邮件、通用套接字、队列或特定于操作系统的日志记录机制(如 syslog 或 Windows NT 事件日志)。 目标由 "
":dfn:`handler` 类提供。 如果你有任何内置处理器类未满足的特殊要求,则可以创建自己的日志目标类。"
#:../../howto/logging.rst:357
msgid""
"By default, no destination is set for any logging messages. You can specify "
"a destination (such as console or file) by using :func:`basicConfig` as in "
"the tutorial examples. If you call the functions :func:`debug`, "
":func:`info`, :func:`warning`, :func:`error` and :func:`critical`, they will"
" check to see if no destination is set; and if one is not set, they will set"
" a destination of the console (``sys.stderr``) and a default format for the "
"displayed message before delegating to the root logger to do the actual "
"message output."
msgstr""
"默认情况下,没有为任何日志消息设置目标。 你可以使用 :func:`basicConfig` 指定目标(例如控制台或文件),如教程示例中所示。 "
"如果你调用函数 :func:`debug` 、 :func:`info` 、 :func:`warning` 、 :func:`error` 和 "
":func:`critical` ,它们将检查是否有设置目标;如果没有设置,将在委托给根记录器进行实际的消息输出之前设置目标为控制台( "
"``sys.stderr`` )并设置显示消息的默认格式。"
#:../../howto/logging.rst:365
msgid"The default format set by :func:`basicConfig` for messages is:"
msgstr"由 :func:`basicConfig` 设置的消息默认格式为:"
#:../../howto/logging.rst:371
msgid""
"You can change this by passing a format string to :func:`basicConfig` with "
"the *format* keyword argument. For all options regarding how a format string"
" is constructed, see :ref:`formatter-objects`."
msgstr""
"你可以通过使用 *format* 参数将格式字符串传递给 :func:`basicConfig` 来更改此设置。有关如何构造格式字符串的所有选项,请参阅"
" :ref:`formatter-objects` 。"
#:../../howto/logging.rst:376
msgid"Logging Flow"
msgstr"记录流程"
#:../../howto/logging.rst:378
msgid""
"The flow of log event information in loggers and handlers is illustrated in "
"the following diagram."
msgstr"记录器和处理器中的日志事件信息流程如下图所示。"
#:../../howto/logging.rst:385
msgid"Loggers"
msgstr"记录器"
#:../../howto/logging.rst:387
msgid""
":class:`Logger` objects have a threefold job. First, they expose several "
"methods to application code so that applications can log messages at "
"runtime. Second, logger objects determine which log messages to act upon "
"based upon severity (the default filtering facility) or filter objects. "
"Third, logger objects pass along relevant log messages to all interested log"
" handlers."
msgstr""
":class:`Logger` "
"对象有三重任务。首先,它们向应用程序代码公开了几种方法,以便应用程序可以在运行时记录消息。其次,记录器对象根据严重性(默认过滤工具)或过滤器对象确定要处理的日志消息。第三,记录器对象将相关的日志消息传递给所有感兴趣的日志处理器。"
#:../../howto/logging.rst:393
msgid""
"The most widely used methods on logger objects fall into two categories: "
"configuration and message sending."
msgstr"记录器对象上使用最广泛的方法分为两类:配置和消息发送。"
#:../../howto/logging.rst:396
msgid"These are the most common configuration methods:"
msgstr"这些是最常见的配置方法:"
#:../../howto/logging.rst:398
msgid""
":meth:`Logger.setLevel` specifies the lowest-severity log message a logger "
"will handle, where debug is the lowest built-in severity level and critical "
"is the highest built-in severity. For example, if the severity level is "
"INFO, the logger will handle only INFO, WARNING, ERROR, and CRITICAL "
"messages and will ignore DEBUG messages."
msgstr""
":meth:`Logger.setLevel` 指定记录器将处理的最低严重性日志消息,其中 debug 是最低内置严重性级别, critical "
"是最高内置严重性级别。 例如,如果严重性级别为 INFO ,则记录器将仅处理 INFO 、 WARNING 、 ERROR 和 CRITICAL "
"消息,并将忽略 DEBUG 消息。"
#:../../howto/logging.rst:404
msgid""
":meth:`Logger.addHandler` and :meth:`Logger.removeHandler` add and remove "
"handler objects from the logger object. Handlers are covered in more detail"
" in :ref:`handler-basic`."
msgstr""
":meth:`Logger.addHandler` 和 :meth:`Logger.removeHandler` "
"从记录器对象中添加和删除处理器对象。处理器在以下内容中有更详细的介绍 :ref:`handler-basic` 。"
#:../../howto/logging.rst:408
msgid""
":meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove "
"filter objects from the logger object. Filters are covered in more detail "
"in :ref:`filter`."
msgstr""
":meth:`Logger.addFilter` 和 :meth:`Logger.removeFilter` 可以添加或移除记录器对象中的过滤器。 "
":ref:`filter` 包含更多的过滤器细节。"
#:../../howto/logging.rst:412
msgid""
"You don't need to always call these methods on every logger you create. See "
"the last two paragraphs in this section."
msgstr"你不需要总是在你创建的每个记录器上都调用这些方法。 请参阅本节的最后两段。"
#:../../howto/logging.rst:415
msgid""
"With the logger object configured, the following methods create log "
"messages:"
msgstr"配置记录器对象后,以下方法将创建日志消息:"
#:../../howto/logging.rst:417
msgid""
":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, "
":meth:`Logger.error`, and :meth:`Logger.critical` all create log records "
"with a message and a level that corresponds to their respective method "
"names. The message is actually a format string, which may contain the "
"standard string substitution syntax of ``%s``, ``%d``, ``%f``, and so on. "
"The rest of their arguments is a list of objects that correspond with the "
"substitution fields in the message. With regard to ``**kwargs``, the "
"logging methods care only about a keyword of ``exc_info`` and use it to "
"determine whether to log exception information."
msgstr""
":meth:`Logger.debug` 、 :meth:`Logger.info` 、 :meth:`Logger.warning` 、 "
":meth:`Logger.error` 和 :meth:`Logger.critical` "
"都创建日志记录,包含消息和与其各自方法名称对应的级别。该消息实际上是一个格式化字符串,它可能包含标题字符串替换语法 ``%s`` 、 ``%d`` 、 "
"``%f`` 等等。其余参数是与消息中的替换字段对应的对象列表。关于 ``**kwargs`` ,日志记录方法只关注 ``exc_info`` "
"的关键字,并用它来确定是否记录异常信息。"
#:../../howto/logging.rst:427
msgid""
":meth:`Logger.exception` creates a log message similar to "
":meth:`Logger.error`. The difference is that :meth:`Logger.exception` dumps"
" a stack trace along with it. Call this method only from an exception "
"handler."
msgstr""
":meth:`Logger.exception` 创建与 :meth:`Logger.error` 相似的日志信息。 不同之处是, "
":meth:`Logger.exception` 同时还记录当前的堆栈追踪。仅从异常处理程序调用此方法。"
#:../../howto/logging.rst:431
msgid""
":meth:`Logger.log` takes a log level as an explicit argument. This is a "
"little more verbose for logging messages than using the log level "
"convenience methods listed above, but this is how to log at custom log "
"levels."
msgstr""
":meth:`Logger.log` "
"将日志级别作为显式参数。对于记录消息而言,这比使用上面列出的日志级别便利方法更加冗长,但这是使用自定义日志级别的方法。"
#:../../howto/logging.rst:435
msgid""
":func:`getLogger` returns a reference to a logger instance with the "
"specified name if it is provided, or ``root`` if not. The names are period-"
"separated hierarchical structures. Multiple calls to :func:`getLogger` with"
" the same name will return a reference to the same logger object. Loggers "
"that are further down in the hierarchical list are children of loggers "
"higher up in the list. For example, given a logger with a name of ``foo``, "
"loggers with names of ``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all "
"descendants of ``foo``."
msgstr""
":func:`getLogger` 返回对具有指定名称的记录器实例的引用(如果已提供),或者如果没有则返回 ``root`` "
"。名称是以句点分隔的层次结构。多次调用 :func:`getLogger` "
"具有相同的名称将返回对同一记录器对象的引用。在分层列表中较低的记录器是列表中较高的记录器的子项。例如,给定一个名为 ``foo`` 的记录器,名称为 "
"``foo.bar`` 、 ``foo.bar.baz`` 和 ``foo.bam`` 的记录器都是 ``foo`` 子项。"
#:../../howto/logging.rst:443
msgid""
"Loggers have a concept of *effective level*. If a level is not explicitly "
"set on a logger, the level of its parent is used instead as its effective "
"level. If the parent has no explicit level set, *its* parent is examined, "
"and so on - all ancestors are searched until an explicitly set level is "
"found. The root logger always has an explicit level set (``WARNING`` by "
"default). When deciding whether to process an event, the effective level of "
"the logger is used to determine whether the event is passed to the logger's "
"handlers."
msgstr""
"记录器具有 *有效等级* 的概念。如果未在记录器上显式设置级别,则使用其父记录器的级别作为其有效级别。如果父记录器没有明确的级别设置,则检查 *其* "
"父级。依此类推,搜索所有上级元素,直到找到明确设置的级别。根记录器始终具有明确的级别配置(默认情况下为 ``WARNING`` "
")。在决定是否处理事件时,记录器的有效级别用于确定事件是否传递给记录器相关的处理器。"
#:../../howto/logging.rst:451
msgid""
"Child loggers propagate messages up to the handlers associated with their "
"ancestor loggers. Because of this, it is unnecessary to define and configure"
" handlers for all the loggers an application uses. It is sufficient to "
"configure handlers for a top-level logger and create child loggers as "
"needed. (You can, however, turn off propagation by setting the *propagate* "
"attribute of a logger to ``False``.)"
msgstr""
"子记录器将消息传播到与其父级记录器关联的处理器。因此,不必为应用程序使用的所有记录器定义和配置处理器。一般为顶级记录器配置处理器,再根据需要创建子记录器就足够了。(但是,你可以通过将记录器的"
" *propagate* 属性设置为 ``False`` 来关闭传播。)"
#:../../howto/logging.rst:462
msgid"Handlers"
msgstr"处理器"
#:../../howto/logging.rst:464
msgid""
":class:`~logging.Handler` objects are responsible for dispatching the "
"appropriate log messages (based on the log messages' severity) to the "
"handler's specified destination. :class:`Logger` objects can add zero or "
"more handler objects to themselves with an :meth:`~Logger.addHandler` "
"method. As an example scenario, an application may want to send all log "
"messages to a log file, all log messages of error or higher to stdout, and "
"all messages of critical to an email address. This scenario requires three "
"individual handlers where each handler is responsible for sending messages "
"of a specific severity to a specific location."
msgstr""
":class:`~logging.Handler` 对象负责将适当的日志消息(基于日志消息的严重性)分派给处理器的指定目标。 "
":class:`Logger` 对象可以使用 :meth:`~Logger.addHandler` "
"方法向自己添加零个或多个处理器对象。作为示例场景,应用程序可能希望将所有日志消息发送到日志文件,将错误或更高的所有日志消息发送到标准输出,以及将所有关键消息发送至一个邮件地址。"
" 此方案需要三个单独的处理器,其中每个处理器负责将特定严重性的消息发送到特定位置。"
#:../../howto/logging.rst:474
msgid""
"The standard library includes quite a few handler types (see :ref:`useful-"
"handlers`); the tutorials use mainly :class:`StreamHandler` and "
":class:`FileHandler` in its examples."
msgstr""
"标准库包含很多处理器类型(参见 :ref:`useful-handlers` );教程主要使用 :class:`StreamHandler` 和 "
":class:`FileHandler` 。"
#:../../howto/logging.rst:478
msgid""
"There are very few methods in a handler for application developers to "
"concern themselves with. The only handler methods that seem relevant for "
"application developers who are using the built-in handler objects (that is, "
"not creating custom handlers) are the following configuration methods:"
msgstr"处理器中很少有方法可供应用程序开发人员使用。使用内置处理器对象(即不创建自定义处理器)的应用程序开发人员能用到的仅有以下配置方法:"
#:../../howto/logging.rst:483
msgid""
"The :meth:`~Handler.setLevel` method, just as in logger objects, specifies "
"the lowest severity that will be dispatched to the appropriate destination."
" Why are there two :meth:`~Handler.setLevel` methods? The level set in the"
" logger determines which severity of messages it will pass to its handlers."
" The level set in each handler determines which messages that handler will "
"send on."
msgstr""
":meth:`~Handler.setLevel` 方法,就像在日志记录器对象中一样,指定将被分派到适当目标的最低严重性。 为什么有两个 "
":meth:`~Handler.setLevel` 方法? 在日志记录器中设置的级别确定要传递给其处理器的消息的严重性。 "
"每个处理器中设置的级别则确定该处理器将发送哪些消息。"
#:../../howto/logging.rst:489
msgid""
":meth:`~Handler.setFormatter` selects a Formatter object for this handler to"
" use."
msgstr":meth:`~Handler.setFormatter` 选择一个该处理器使用的 Formatter 对象。"
#:../../howto/logging.rst:492
msgid""
":meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively "
"configure and deconfigure filter objects on handlers."
msgstr""
":meth:`~Handler.addFilter` 和 :meth:`~Handler.removeFilter` "
"分别在处理器上配置和取消配置过滤器对象。"
#:../../howto/logging.rst:495
msgid""
"Application code should not directly instantiate and use instances of "
":class:`Handler`. Instead, the :class:`Handler` class is a base class that "
"defines the interface that all handlers should have and establishes some "
"default behavior that child classes can use (or override)."
msgstr""
"应用程序代码不应直接实例化并使用 :class:`Handler` 的实例。 相反, :class:`Handler` "
"类是一个基类,它定义了所有处理器应该具有的接口,并建立了子类可以使用(或覆盖)的一些默认行为。"
#:../../howto/logging.rst:502
msgid"Formatters"
msgstr"格式器"
#:../../howto/logging.rst:504
msgid""
"Formatter objects configure the final order, structure, and contents of the "
"log message. Unlike the base :class:`logging.Handler` class, application "
"code may instantiate formatter classes, although you could likely subclass "
"the formatter if your application needs special behavior. The constructor "
"takes three optional arguments -- a message format string, a date format "
"string and a style indicator."
msgstr""
"格式化器对象配置日志消息的最终顺序、结构和内容。 与 :class:`logging.Handler` "
"类不同,应用程序代码可以实例化格式器类,但如果应用程序需要特殊行为,则可能会对格式化器进行子类化定制。构造函数有三个可选参数 —— "
"消息格式字符串、日期格式字符串和样式指示符。"
#:../../howto/logging.rst:513
msgid""
"If there is no message format string, the default is to use the raw message."
" If there is no date format string, the default date format is:"
msgstr"如果没有消息格式字符串,则默认使用原始消息。如果没有日期格式字符串,则默认日期格式为:"
#:../../howto/logging.rst:520
msgid""
"with the milliseconds tacked on at the end. The ``style`` is one of ``'%'``,"
" ``'{'``, or ``'$'``. If one of these is not specified, then ``'%'`` will be"
" used."
msgstr""
"在末尾加上毫秒数。 ``style`` 是 ``'%'``, ``'{'`` 或 ``'{TX-PL-LABEL}#x27;`` 之一。 "
"如果未指定其中之一,则将使用 ``'%'``。"
#:../../howto/logging.rst:523
msgid""
"If the ``style`` is ``'%'``, the message format string uses ``%(<dictionary "
"key>)s`` styled string substitution; the possible keys are documented in "
":ref:`logrecord-attributes`. If the style is ``'{'``, the message format "
"string is assumed to be compatible with :meth:`str.format` (using keyword "
"arguments), while if the style is ``'$'`` then the message format string "
"should conform to what is expected by :meth:`string.Template.substitute`."
msgstr""
"如果 ``style`` 为 ``'%'``,则消息格式字符串将使用 ``%(<dictionary key>)s`` "
"样式的字符串替换;可用的键值记录在 :ref:`logrecord-attributes` 中。 如果样式为 ``'{'``,则将假定消息格式字符串与 "
":meth:`str.format` 兼容(使用关键字参数),而如果样式为 ``'{TX-PL-LABEL}#x27;`` 则消息格式字符串应当符合 "
":meth:`string.Template.substitute` 的预期。"
#:../../howto/logging.rst:530
msgid"Added the ``style`` parameter."
msgstr"添加 ``style`` 形参。"
#:../../howto/logging.rst:533
msgid""
"The following message format string will log the time in a human-readable "
"format, the severity of the message, and the contents of the message, in "
"that order::"
msgstr"以下消息格式字符串将以人类可读的格式记录时间、消息的严重性以及消息的内容,按此顺序::"
#:../../howto/logging.rst:539
msgid""
"Formatters use a user-configurable function to convert the creation time of "
"a record to a tuple. By default, :func:`time.localtime` is used; to change "
"this for a particular formatter instance, set the ``converter`` attribute of"
" the instance to a function with the same signature as "
":func:`time.localtime` or :func:`time.gmtime`. To change it for all "
"formatters, for example if you want all logging times to be shown in GMT, "
"set the ``converter`` attribute in the Formatter class (to ``time.gmtime`` "
"for GMT display)."
msgstr""
"格式器通过用户可配置的函数将记录的创建时间转换为元组。 默认情况下,使用 :func:`time.localtime` "
";要为特定格式器实例更改此项,请将实例的 ``converter`` 属性设置为与 :func:`time.localtime` 或 "
":func:`time.gmtime` 具有相同签名的函数。 要为所有格式器更改它,例如,如果你希望所有记录时间都以 GMT 显示,请在格式器类中设置 "
"``converter`` 属性(对于 GMT 显示,设置为 ``time.gmtime`` )。"
#:../../howto/logging.rst:549
msgid"Configuring Logging"
msgstr"配置日志记录"
#:../../howto/logging.rst:553
msgid"Programmers can configure logging in three ways:"
msgstr"开发者可以通过三种方式配置日志记录:"
#:../../howto/logging.rst:555
msgid""
"Creating loggers, handlers, and formatters explicitly using Python code that"
" calls the configuration methods listed above."
msgstr"使用调用上面列出的配置方法的 Python 代码显式创建记录器、处理器和格式器。"
#:../../howto/logging.rst:557
msgid""
"Creating a logging config file and reading it using the :func:`fileConfig` "
"function."
msgstr"创建日志配置文件并使用 :func:`fileConfig` 函数读取它。"
#:../../howto/logging.rst:559
msgid""
"Creating a dictionary of configuration information and passing it to the "
":func:`dictConfig` function."
msgstr"创建配置信息字典并将其传递给 :func:`dictConfig` 函数。"
#:../../howto/logging.rst:562
msgid""
"For the reference documentation on the last two options, see :ref:`logging-"
"config-api`. The following example configures a very simple logger, a "
"console handler, and a simple formatter using Python code::"
msgstr""
"有关最后两个选项的参考文档,请参阅 :ref:`logging-config-api` 。 以下示例使用 Python "
"代码配置一个非常简单的记录器、一个控制台处理器和一个简单的格式器::"
#:../../howto/logging.rst:592
msgid""
"Running this module from the command line produces the following output:"
msgstr"从命令行运行此模块将生成以下输出:"
#:../../howto/logging.rst:603
msgid""
"The following Python module creates a logger, handler, and formatter nearly "
"identical to those in the example listed above, with the only difference "
"being the names of the objects::"
msgstr"以下 Python 模块创建的记录器、处理器和格式器几乎与上面列出的示例中的相同,唯一的区别是对象的名称::"
#:../../howto/logging.rst:622
msgid"Here is the logging.conf file:"
msgstr"这是 logging.conf 文件:"
#:../../howto/logging.rst:654
msgid""
"The output is nearly identical to that of the non-config-file-based example:"
msgstr"其输出与不基于配置文件的示例几乎相同:"
#:../../howto/logging.rst:665
msgid""
"You can see that the config file approach has a few advantages over the "
"Python code approach, mainly separation of configuration and code and the "
"ability of noncoders to easily modify the logging properties."
msgstr"你可以看到配置文件方法相较于 Python 代码方法有一些优势,主要是配置和代码的分离以及非开发者轻松修改日志记录属性的能力。"
#:../../howto/logging.rst:669
msgid""
"The :func:`fileConfig` function takes a default parameter, "
"``disable_existing_loggers``, which defaults to ``True`` for reasons of "
"backward compatibility. This may or may not be what you want, since it will "
"cause any non-root loggers existing before the :func:`fileConfig` call to be"
" disabled unless they (or an ancestor) are explicitly named in the "
"configuration. Please refer to the reference documentation for more "
"information, and specify ``False`` for this parameter if you wish."
msgstr""
":func:`fileConfig` 函数接受一个默认参数 ``disable_existing_loggers`` ,出于向后兼容的原因,默认为 "
"``True`` 。这可能与您的期望不同,因为除非在配置中明确命名它们(或其父级),否则它将导致在 :func:`fileConfig` "
"调用之前存在的任何非 root 记录器被禁用。有关更多信息,请参阅参考文档,如果需要,请将此参数指定为 ``False`` 。"
#:../../howto/logging.rst:677
msgid""
"The dictionary passed to :func:`dictConfig` can also specify a Boolean value"
" with key ``disable_existing_loggers``, which if not specified explicitly in"
" the dictionary also defaults to being interpreted as ``True``. This leads "
"to the logger-disabling behaviour described above, which may not be what you"
" want - in which case, provide the key explicitly with a value of ``False``."
msgstr""
"传递给 :func:`dictConfig` 的字典也可以用键 ``disable_existing_loggers`` "
"指定一个布尔值,如果没有在字典中明确指定,也默认被解释为 ``True`` "
"。这会导致上面描述的记录器禁用行为,这可能与你的期望不同——在这种情况下,请明确地为其提供 ``False`` 值。"
#:../../howto/logging.rst:687
msgid""
"Note that the class names referenced in config files need to be either "
"relative to the logging module, or absolute values which can be resolved "
"using normal import mechanisms. Thus, you could use either "
":class:`~logging.handlers.WatchedFileHandler` (relative to the logging "
"module) or ``mypackage.mymodule.MyHandler`` (for a class defined in package "
"``mypackage`` and module ``mymodule``, where ``mypackage`` is available on "
"the Python import path)."
msgstr""
"请注意,配置文件中引用的类名称需要相对于日志记录模块,或者可以使用常规导入机制解析的绝对值。因此,你可以使用 "
":class:`~logging.handlers.WatchedFileHandler` (相对于日志记录模块)或 "
"``mypackage.mymodule.MyHandler`` (对于在 ``mypackage`` 包中定义的类和模块 ``mymodule`` "
",其中 ``mypackage`` 在 Python 导入路径上可用)。"
#:../../howto/logging.rst:695
msgid""
"In Python 3.2, a new means of configuring logging has been introduced, using"
" dictionaries to hold configuration information. This provides a superset of"
" the functionality of the config-file-based approach outlined above, and is "
"the recommended configuration method for new applications and deployments. "
"Because a Python dictionary is used to hold configuration information, and "
"since you can populate that dictionary using different means, you have more "
"options for configuration. For example, you can use a configuration file in "