blob: 5e21474812cba8f52a92e20da38922bda2cbbb7e [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001:mod:`logging` --- Logging facility for Python
2==============================================
3
4.. module:: logging
Vinay Sajip5dbca9c2011-04-08 11:40:38 +01005 :synopsis: Flexible event logging system for applications.
Georg Brandl8ec7f652007-08-15 14:28:01 +00006
7
8.. moduleauthor:: Vinay Sajip <vinay_sajip@red-dove.com>
9.. sectionauthor:: Vinay Sajip <vinay_sajip@red-dove.com>
10
11
Georg Brandl8ec7f652007-08-15 14:28:01 +000012.. index:: pair: Errors; logging
13
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010014.. sidebar:: Important
15
16 This page contains the API reference information. For tutorial
17 information and discussion of more advanced topics, see
18
19 * :ref:`Basic Tutorial <logging-basic-tutorial>`
20 * :ref:`Advanced Tutorial <logging-advanced-tutorial>`
21 * :ref:`Logging Cookbook <logging-cookbook>`
22
Vinay Sajip6971f2e2013-09-05 22:57:20 +010023**Source code:** :source:`Lib/logging/__init__.py`
24
25--------------
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010026
Georg Brandl8ec7f652007-08-15 14:28:01 +000027.. versionadded:: 2.3
28
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010029This module defines functions and classes which implement a flexible event
30logging system for applications and libraries.
Georg Brandlc37f2882007-12-04 17:46:27 +000031
32The key benefit of having the logging API provided by a standard library module
33is that all Python modules can participate in logging, so your application log
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010034can include your own messages integrated with messages from third-party
35modules.
Georg Brandlc37f2882007-12-04 17:46:27 +000036
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010037The module provides a lot of functionality and flexibility. If you are
38unfamiliar with logging, the best way to get to grips with it is to see the
39tutorials (see the links on the right).
Georg Brandlc37f2882007-12-04 17:46:27 +000040
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010041The basic classes defined by the module, together with their functions, are
42listed below.
Georg Brandlc37f2882007-12-04 17:46:27 +000043
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010044* Loggers expose the interface that application code directly uses.
45* Handlers send the log records (created by loggers) to the appropriate
46 destination.
47* Filters provide a finer grained facility for determining which log records
48 to output.
49* Formatters specify the layout of log records in the final output.
Georg Brandlc37f2882007-12-04 17:46:27 +000050
Georg Brandlc37f2882007-12-04 17:46:27 +000051
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010052.. _logger:
Georg Brandlc37f2882007-12-04 17:46:27 +000053
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010054Logger Objects
Georg Brandlc37f2882007-12-04 17:46:27 +000055--------------
56
Vinay Sajip2a1c13b2012-04-10 19:52:06 +010057Loggers have the following attributes and methods. Note that Loggers are never
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010058instantiated directly, but always through the module-level function
Vinay Sajip2a1c13b2012-04-10 19:52:06 +010059``logging.getLogger(name)``. Multiple calls to :func:`getLogger` with the same
60name will always return a reference to the same Logger object.
61
62The ``name`` is potentially a period-separated hierarchical value, like
63``foo.bar.baz`` (though it could also be just plain ``foo``, for example).
64Loggers that are further down in the hierarchical list are children of loggers
65higher up in the list. For example, given a logger with a name of ``foo``,
66loggers with names of ``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all
67descendants of ``foo``. The logger name hierarchy is analogous to the Python
68package hierarchy, and identical to it if you organise your loggers on a
69per-module basis using the recommended construction
70``logging.getLogger(__name__)``. That's because in a module, ``__name__``
71is the module's name in the Python package namespace.
Georg Brandl8ec7f652007-08-15 14:28:01 +000072
Vinay Sajipcb309c52013-01-21 19:43:51 +000073
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010074.. class:: Logger
Georg Brandl8ec7f652007-08-15 14:28:01 +000075
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010076.. attribute:: Logger.propagate
Georg Brandl8ec7f652007-08-15 14:28:01 +000077
Vinay Sajipcb309c52013-01-21 19:43:51 +000078 If this evaluates to true, events logged to this logger will be passed to the
79 handlers of higher level (ancestor) loggers, in addition to any handlers
80 attached to this logger. Messages are passed directly to the ancestor
81 loggers' handlers - neither the level nor filters of the ancestor loggers in
82 question are considered.
Vinay Sajip36398072011-11-23 08:51:35 +000083
84 If this evaluates to false, logging messages are not passed to the handlers
85 of ancestor loggers.
86
Benjamin Petersonc016f462011-12-30 13:47:25 -060087 The constructor sets this attribute to ``True``.
Vinay Sajip89e1ae22010-09-17 10:09:04 +000088
Vinay Sajip8a459d92013-01-21 21:56:35 +000089 .. note:: If you attach a handler to a logger *and* one or more of its
90 ancestors, it may emit the same record multiple times. In general, you
91 should not need to attach a handler to more than one logger - if you just
92 attach it to the appropriate logger which is highest in the logger
93 hierarchy, then it will see all events logged by all descendant loggers,
94 provided that their propagate setting is left set to ``True``. A common
95 scenario is to attach handlers only to the root logger, and to let
96 propagation take care of the rest.
Vinay Sajip89e1ae22010-09-17 10:09:04 +000097
Vinay Sajip5dbca9c2011-04-08 11:40:38 +010098.. method:: Logger.setLevel(lvl)
99
100 Sets the threshold for this logger to *lvl*. Logging messages which are less
101 severe than *lvl* will be ignored. When a logger is created, the level is set to
102 :const:`NOTSET` (which causes all messages to be processed when the logger is
103 the root logger, or delegation to the parent when the logger is a non-root
104 logger). Note that the root logger is created with level :const:`WARNING`.
105
106 The term 'delegation to the parent' means that if a logger has a level of
107 NOTSET, its chain of ancestor loggers is traversed until either an ancestor with
108 a level other than NOTSET is found, or the root is reached.
109
110 If an ancestor is found with a level other than NOTSET, then that ancestor's
111 level is treated as the effective level of the logger where the ancestor search
112 began, and is used to determine how a logging event is handled.
113
114 If the root is reached, and it has a level of NOTSET, then all messages will be
115 processed. Otherwise, the root's level will be used as the effective level.
116
Vinay Sajipd46a31f2013-12-19 11:42:18 +0000117 See :ref:`levels` for a list of levels.
118
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100119
120.. method:: Logger.isEnabledFor(lvl)
121
122 Indicates if a message of severity *lvl* would be processed by this logger.
123 This method checks first the module-level level set by
124 ``logging.disable(lvl)`` and then the logger's effective level as determined
125 by :meth:`getEffectiveLevel`.
126
127
128.. method:: Logger.getEffectiveLevel()
129
130 Indicates the effective level for this logger. If a value other than
131 :const:`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise,
132 the hierarchy is traversed towards the root until a value other than
Vinay Sajipf40a4072014-09-18 17:46:58 +0100133 :const:`NOTSET` is found, and that value is returned. The value returned is
134 an integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO`
135 etc.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100136
137
138.. method:: Logger.getChild(suffix)
139
140 Returns a logger which is a descendant to this logger, as determined by the suffix.
141 Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same
142 logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a
143 convenience method, useful when the parent logger is named using e.g. ``__name__``
144 rather than a literal string.
145
146 .. versionadded:: 2.7
147
148
149.. method:: Logger.debug(msg, *args, **kwargs)
150
151 Logs a message with level :const:`DEBUG` on this logger. The *msg* is the
152 message format string, and the *args* are the arguments which are merged into
153 *msg* using the string formatting operator. (Note that this means that you can
154 use keywords in the format string, together with a single dictionary argument.)
155
156 There are two keyword arguments in *kwargs* which are inspected: *exc_info*
157 which, if it does not evaluate as false, causes exception information to be
158 added to the logging message. If an exception tuple (in the format returned by
159 :func:`sys.exc_info`) is provided, it is used; otherwise, :func:`sys.exc_info`
160 is called to get the exception information.
161
162 The second keyword argument is *extra* which can be used to pass a
163 dictionary which is used to populate the __dict__ of the LogRecord created for
164 the logging event with user-defined attributes. These custom attributes can then
165 be used as you like. For example, they could be incorporated into logged
166 messages. For example::
167
168 FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
169 logging.basicConfig(format=FORMAT)
Jason R. Coombsd6a80ee2012-03-07 10:24:04 -0500170 d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100171 logger = logging.getLogger('tcpserver')
172 logger.warning('Protocol problem: %s', 'connection reset', extra=d)
173
174 would print something like ::
175
176 2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset
177
178 The keys in the dictionary passed in *extra* should not clash with the keys used
179 by the logging system. (See the :class:`Formatter` documentation for more
180 information on which keys are used by the logging system.)
181
182 If you choose to use these attributes in logged messages, you need to exercise
183 some care. In the above example, for instance, the :class:`Formatter` has been
184 set up with a format string which expects 'clientip' and 'user' in the attribute
185 dictionary of the LogRecord. If these are missing, the message will not be
186 logged because a string formatting exception will occur. So in this case, you
187 always need to pass the *extra* dictionary with these keys.
188
189 While this might be annoying, this feature is intended for use in specialized
190 circumstances, such as multi-threaded servers where the same code executes in
191 many contexts, and interesting conditions which arise are dependent on this
192 context (such as remote client IP address and authenticated user name, in the
193 above example). In such circumstances, it is likely that specialized
194 :class:`Formatter`\ s would be used with particular :class:`Handler`\ s.
195
196
197.. method:: Logger.info(msg, *args, **kwargs)
198
199 Logs a message with level :const:`INFO` on this logger. The arguments are
200 interpreted as for :meth:`debug`.
201
202
203.. method:: Logger.warning(msg, *args, **kwargs)
204
205 Logs a message with level :const:`WARNING` on this logger. The arguments are
206 interpreted as for :meth:`debug`.
207
208
209.. method:: Logger.error(msg, *args, **kwargs)
210
211 Logs a message with level :const:`ERROR` on this logger. The arguments are
212 interpreted as for :meth:`debug`.
213
214
215.. method:: Logger.critical(msg, *args, **kwargs)
216
217 Logs a message with level :const:`CRITICAL` on this logger. The arguments are
218 interpreted as for :meth:`debug`.
219
220
221.. method:: Logger.log(lvl, msg, *args, **kwargs)
222
223 Logs a message with integer level *lvl* on this logger. The other arguments are
224 interpreted as for :meth:`debug`.
225
226
Vinay Sajip51f80c12014-04-15 23:11:15 +0100227.. method:: Logger.exception(msg, *args, **kwargs)
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100228
229 Logs a message with level :const:`ERROR` on this logger. The arguments are
Vinay Sajip6fcb9a52015-01-06 11:10:12 +0000230 interpreted as for :meth:`debug`, except that any passed *exc_info* is not
231 inspected. Exception info is always added to the logging message. This method
232 should only be called from an exception handler.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100233
234
235.. method:: Logger.addFilter(filt)
236
237 Adds the specified filter *filt* to this logger.
238
239
240.. method:: Logger.removeFilter(filt)
241
242 Removes the specified filter *filt* from this logger.
243
244
245.. method:: Logger.filter(record)
246
247 Applies this logger's filters to the record and returns a true value if the
Vinay Sajipcb309c52013-01-21 19:43:51 +0000248 record is to be processed. The filters are consulted in turn, until one of
249 them returns a false value. If none of them return a false value, the record
250 will be processed (passed to handlers). If one returns a false value, no
251 further processing of the record occurs.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100252
253
254.. method:: Logger.addHandler(hdlr)
255
256 Adds the specified handler *hdlr* to this logger.
257
258
259.. method:: Logger.removeHandler(hdlr)
260
261 Removes the specified handler *hdlr* from this logger.
262
263
264.. method:: Logger.findCaller()
265
266 Finds the caller's source filename and line number. Returns the filename, line
267 number and function name as a 3-element tuple.
268
269 .. versionchanged:: 2.4
270 The function name was added. In earlier versions, the filename and line
271 number were returned as a 2-element tuple.
272
273.. method:: Logger.handle(record)
274
275 Handles a record by passing it to all handlers associated with this logger and
276 its ancestors (until a false value of *propagate* is found). This method is used
277 for unpickled records received from a socket, as well as those created locally.
278 Logger-level filtering is applied using :meth:`~Logger.filter`.
279
280
281.. method:: Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None)
282
283 This is a factory method which can be overridden in subclasses to create
284 specialized :class:`LogRecord` instances.
285
286 .. versionchanged:: 2.5
287 *func* and *extra* were added.
288
Vinay Sajipd46a31f2013-12-19 11:42:18 +0000289
290.. _levels:
291
292Logging Levels
293--------------
294
295The numeric values of logging levels are given in the following table. These are
296primarily of interest if you want to define your own levels, and need them to
297have specific values relative to the predefined levels. If you define a level
298with the same numeric value, it overwrites the predefined value; the predefined
299name is lost.
300
301+--------------+---------------+
302| Level | Numeric value |
303+==============+===============+
304| ``CRITICAL`` | 50 |
305+--------------+---------------+
306| ``ERROR`` | 40 |
307+--------------+---------------+
308| ``WARNING`` | 30 |
309+--------------+---------------+
310| ``INFO`` | 20 |
311+--------------+---------------+
312| ``DEBUG`` | 10 |
313+--------------+---------------+
314| ``NOTSET`` | 0 |
315+--------------+---------------+
316
317
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100318.. _handler:
319
320Handler Objects
Vinay Sajipb5902e62009-01-15 22:48:13 +0000321---------------
322
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100323Handlers have the following attributes and methods. Note that :class:`Handler`
324is never instantiated directly; this class acts as a base for more useful
325subclasses. However, the :meth:`__init__` method in subclasses needs to call
326:meth:`Handler.__init__`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000327
Georg Brandl8ec7f652007-08-15 14:28:01 +0000328
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100329.. method:: Handler.__init__(level=NOTSET)
Vinay Sajipb1a15e42009-01-15 23:04:47 +0000330
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100331 Initializes the :class:`Handler` instance by setting its level, setting the list
332 of filters to the empty list and creating a lock (using :meth:`createLock`) for
333 serializing access to an I/O mechanism.
Vinay Sajipc2211ad2009-01-10 19:22:57 +0000334
Georg Brandl8ec7f652007-08-15 14:28:01 +0000335
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100336.. method:: Handler.createLock()
Georg Brandl8ec7f652007-08-15 14:28:01 +0000337
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100338 Initializes a thread lock which can be used to serialize access to underlying
339 I/O functionality which may not be threadsafe.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000340
Georg Brandl8ec7f652007-08-15 14:28:01 +0000341
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100342.. method:: Handler.acquire()
Georg Brandl8ec7f652007-08-15 14:28:01 +0000343
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100344 Acquires the thread lock created with :meth:`createLock`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000345
Georg Brandl8ec7f652007-08-15 14:28:01 +0000346
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100347.. method:: Handler.release()
Georg Brandl8ec7f652007-08-15 14:28:01 +0000348
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100349 Releases the thread lock acquired with :meth:`acquire`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000350
Vinay Sajipc2211ad2009-01-10 19:22:57 +0000351
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100352.. method:: Handler.setLevel(lvl)
Vinay Sajip213faca2008-12-03 23:22:58 +0000353
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100354 Sets the threshold for this handler to *lvl*. Logging messages which are less
355 severe than *lvl* will be ignored. When a handler is created, the level is set
356 to :const:`NOTSET` (which causes all messages to be processed).
Vinay Sajip213faca2008-12-03 23:22:58 +0000357
Vinay Sajipd46a31f2013-12-19 11:42:18 +0000358 See :ref:`levels` for a list of levels.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000359
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100360.. method:: Handler.setFormatter(form)
Georg Brandl8ec7f652007-08-15 14:28:01 +0000361
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100362 Sets the :class:`Formatter` for this handler to *form*.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000363
Georg Brandl8ec7f652007-08-15 14:28:01 +0000364
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100365.. method:: Handler.addFilter(filt)
366
367 Adds the specified filter *filt* to this handler.
368
369
370.. method:: Handler.removeFilter(filt)
371
372 Removes the specified filter *filt* from this handler.
373
374
375.. method:: Handler.filter(record)
376
377 Applies this handler's filters to the record and returns a true value if the
Vinay Sajipcb309c52013-01-21 19:43:51 +0000378 record is to be processed. The filters are consulted in turn, until one of
379 them returns a false value. If none of them return a false value, the record
380 will be emitted. If one returns a false value, the handler will not emit the
381 record.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100382
383
384.. method:: Handler.flush()
385
386 Ensure all logging output has been flushed. This version does nothing and is
387 intended to be implemented by subclasses.
388
389
390.. method:: Handler.close()
391
392 Tidy up any resources used by the handler. This version does no output but
393 removes the handler from an internal list of handlers which is closed when
394 :func:`shutdown` is called. Subclasses should ensure that this gets called
395 from overridden :meth:`close` methods.
396
397
398.. method:: Handler.handle(record)
399
400 Conditionally emits the specified logging record, depending on filters which may
401 have been added to the handler. Wraps the actual emission of the record with
402 acquisition/release of the I/O thread lock.
403
404
405.. method:: Handler.handleError(record)
406
407 This method should be called from handlers when an exception is encountered
Vinay Sajip7d13cd32012-02-20 18:34:07 +0000408 during an :meth:`emit` call. If the module-level attribute
409 ``raiseExceptions`` is ``False``, exceptions get silently ignored. This is
410 what is mostly wanted for a logging system - most users will not care about
411 errors in the logging system, they are more interested in application
412 errors. You could, however, replace this with a custom handler if you wish.
413 The specified record is the one which was being processed when the exception
414 occurred. (The default value of ``raiseExceptions`` is ``True``, as that is
415 more useful during development).
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100416
417
418.. method:: Handler.format(record)
419
420 Do formatting for a record - if a formatter is set, use it. Otherwise, use the
421 default formatter for the module.
422
423
424.. method:: Handler.emit(record)
425
426 Do whatever it takes to actually log the specified logging record. This version
427 is intended to be implemented by subclasses and so raises a
428 :exc:`NotImplementedError`.
429
430For a list of handlers included as standard, see :mod:`logging.handlers`.
431
432.. _formatter-objects:
433
434Formatter Objects
435-----------------
436
437.. currentmodule:: logging
438
439:class:`Formatter` objects have the following attributes and methods. They are
440responsible for converting a :class:`LogRecord` to (usually) a string which can
441be interpreted by either a human or an external system. The base
442:class:`Formatter` allows a formatting string to be specified. If none is
443supplied, the default value of ``'%(message)s'`` is used.
444
445A Formatter can be initialized with a format string which makes use of knowledge
446of the :class:`LogRecord` attributes - such as the default value mentioned above
447making use of the fact that the user's message and arguments are pre-formatted
448into a :class:`LogRecord`'s *message* attribute. This format string contains
449standard Python %-style mapping keys. See section :ref:`string-formatting`
450for more information on string formatting.
451
452The useful mapping keys in a :class:`LogRecord` are given in the section on
453:ref:`logrecord-attributes`.
454
455
456.. class:: Formatter(fmt=None, datefmt=None)
457
458 Returns a new instance of the :class:`Formatter` class. The instance is
459 initialized with a format string for the message as a whole, as well as a
460 format string for the date/time portion of a message. If no *fmt* is
461 specified, ``'%(message)s'`` is used. If no *datefmt* is specified, the
462 ISO8601 date format is used.
463
464 .. method:: format(record)
465
466 The record's attribute dictionary is used as the operand to a string
467 formatting operation. Returns the resulting string. Before formatting the
468 dictionary, a couple of preparatory steps are carried out. The *message*
469 attribute of the record is computed using *msg* % *args*. If the
470 formatting string contains ``'(asctime)'``, :meth:`formatTime` is called
471 to format the event time. If there is exception information, it is
472 formatted using :meth:`formatException` and appended to the message. Note
473 that the formatted exception information is cached in attribute
474 *exc_text*. This is useful because the exception information can be
475 pickled and sent across the wire, but you should be careful if you have
476 more than one :class:`Formatter` subclass which customizes the formatting
477 of exception information. In this case, you will have to clear the cached
478 value after a formatter has done its formatting, so that the next
479 formatter to handle the event doesn't use the cached value but
480 recalculates it afresh.
481
482
483 .. method:: formatTime(record, datefmt=None)
484
485 This method should be called from :meth:`format` by a formatter which
486 wants to make use of a formatted time. This method can be overridden in
487 formatters to provide for any specific requirement, but the basic behavior
488 is as follows: if *datefmt* (a string) is specified, it is used with
489 :func:`time.strftime` to format the creation time of the
490 record. Otherwise, the ISO8601 format is used. The resulting string is
491 returned.
492
Vinay Sajipad52cb22011-06-13 14:59:36 +0100493 This function uses a user-configurable function to convert the creation
494 time to a tuple. By default, :func:`time.localtime` is used; to change
495 this for a particular formatter instance, set the ``converter`` attribute
496 to a function with the same signature as :func:`time.localtime` or
497 :func:`time.gmtime`. To change it for all formatters, for example if you
498 want all logging times to be shown in GMT, set the ``converter``
499 attribute in the ``Formatter`` class.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100500
501 .. method:: formatException(exc_info)
502
503 Formats the specified exception information (a standard exception tuple as
504 returned by :func:`sys.exc_info`) as a string. This default implementation
505 just uses :func:`traceback.print_exception`. The resulting string is
506 returned.
507
508.. _filter:
509
510Filter Objects
511--------------
512
513``Filters`` can be used by ``Handlers`` and ``Loggers`` for more sophisticated
514filtering than is provided by levels. The base filter class only allows events
515which are below a certain point in the logger hierarchy. For example, a filter
516initialized with 'A.B' will allow events logged by loggers 'A.B', 'A.B.C',
517'A.B.C.D', 'A.B.D' etc. but not 'A.BB', 'B.A.B' etc. If initialized with the
518empty string, all events are passed.
519
520
521.. class:: Filter(name='')
522
523 Returns an instance of the :class:`Filter` class. If *name* is specified, it
524 names a logger which, together with its children, will have its events allowed
525 through the filter. If *name* is the empty string, allows every event.
526
527
528 .. method:: filter(record)
529
530 Is the specified record to be logged? Returns zero for no, nonzero for
531 yes. If deemed appropriate, the record may be modified in-place by this
532 method.
533
Vinay Sajipcb309c52013-01-21 19:43:51 +0000534Note that filters attached to handlers are consulted before an event is
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100535emitted by the handler, whereas filters attached to loggers are consulted
Vinay Sajipcb309c52013-01-21 19:43:51 +0000536whenever an event is logged (using :meth:`debug`, :meth:`info`,
537etc.), before sending an event to handlers. This means that events which have
538been generated by descendant loggers will not be filtered by a logger's filter
539setting, unless the filter has also been applied to those descendant loggers.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100540
541You don't actually need to subclass ``Filter``: you can pass any instance
542which has a ``filter`` method with the same semantics.
543
544Although filters are used primarily to filter records based on more
545sophisticated criteria than levels, they get to see every record which is
546processed by the handler or logger they're attached to: this can be useful if
547you want to do things like counting how many records were processed by a
548particular logger or handler, or adding, changing or removing attributes in
549the LogRecord being processed. Obviously changing the LogRecord needs to be
550done with some care, but it does allow the injection of contextual information
551into logs (see :ref:`filters-contextual`).
552
553.. _log-record:
554
555LogRecord Objects
556-----------------
557
558:class:`LogRecord` instances are created automatically by the :class:`Logger`
559every time something is logged, and can be created manually via
560:func:`makeLogRecord` (for example, from a pickled event received over the
561wire).
562
563
564.. class:: LogRecord(name, level, pathname, lineno, msg, args, exc_info, func=None)
565
566 Contains all the information pertinent to the event being logged.
567
568 The primary information is passed in :attr:`msg` and :attr:`args`, which
569 are combined using ``msg % args`` to create the :attr:`message` field of the
570 record.
571
572 :param name: The name of the logger used to log the event represented by
Vinay Sajipcb309c52013-01-21 19:43:51 +0000573 this LogRecord. Note that this name will always have this
574 value, even though it may be emitted by a handler attached to
575 a different (ancestor) logger.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100576 :param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
Vinay Sajipad52cb22011-06-13 14:59:36 +0100577 Note that this is converted to *two* attributes of the LogRecord:
578 ``levelno`` for the numeric value and ``levelname`` for the
579 corresponding level name.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100580 :param pathname: The full pathname of the source file where the logging call
581 was made.
582 :param lineno: The line number in the source file where the logging call was
583 made.
584 :param msg: The event description message, possibly a format string with
585 placeholders for variable data.
586 :param args: Variable data to merge into the *msg* argument to obtain the
587 event description.
588 :param exc_info: An exception tuple with the current exception information,
589 or *None* if no exception information is available.
590 :param func: The name of the function or method from which the logging call
591 was invoked.
592
593 .. versionchanged:: 2.5
594 *func* was added.
595
596 .. method:: getMessage()
597
598 Returns the message for this :class:`LogRecord` instance after merging any
599 user-supplied arguments with the message. If the user-supplied message
600 argument to the logging call is not a string, :func:`str` is called on it to
601 convert it to a string. This allows use of user-defined classes as
602 messages, whose ``__str__`` method can return the actual format string to
603 be used.
604
605
606.. _logrecord-attributes:
607
608LogRecord attributes
609--------------------
610
611The LogRecord has a number of attributes, most of which are derived from the
612parameters to the constructor. (Note that the names do not always correspond
613exactly between the LogRecord constructor parameters and the LogRecord
614attributes.) These attributes can be used to merge data from the record into
615the format string. The following table lists (in alphabetical order) the
616attribute names, their meanings and the corresponding placeholder in a %-style
617format string.
618
619+----------------+-------------------------+-----------------------------------------------+
620| Attribute name | Format | Description |
621+================+=========================+===============================================+
622| args | You shouldn't need to | The tuple of arguments merged into ``msg`` to |
623| | format this yourself. | produce ``message``. |
624+----------------+-------------------------+-----------------------------------------------+
625| asctime | ``%(asctime)s`` | Human-readable time when the |
626| | | :class:`LogRecord` was created. By default |
627| | | this is of the form '2003-07-08 16:49:45,896' |
628| | | (the numbers after the comma are millisecond |
629| | | portion of the time). |
630+----------------+-------------------------+-----------------------------------------------+
631| created | ``%(created)f`` | Time when the :class:`LogRecord` was created |
632| | | (as returned by :func:`time.time`). |
633+----------------+-------------------------+-----------------------------------------------+
634| exc_info | You shouldn't need to | Exception tuple (à la ``sys.exc_info``) or, |
635| | format this yourself. | if no exception has occurred, *None*. |
636+----------------+-------------------------+-----------------------------------------------+
637| filename | ``%(filename)s`` | Filename portion of ``pathname``. |
638+----------------+-------------------------+-----------------------------------------------+
639| funcName | ``%(funcName)s`` | Name of function containing the logging call. |
640+----------------+-------------------------+-----------------------------------------------+
641| levelname | ``%(levelname)s`` | Text logging level for the message |
642| | | (``'DEBUG'``, ``'INFO'``, ``'WARNING'``, |
643| | | ``'ERROR'``, ``'CRITICAL'``). |
644+----------------+-------------------------+-----------------------------------------------+
645| levelno | ``%(levelno)s`` | Numeric logging level for the message |
646| | | (:const:`DEBUG`, :const:`INFO`, |
647| | | :const:`WARNING`, :const:`ERROR`, |
648| | | :const:`CRITICAL`). |
649+----------------+-------------------------+-----------------------------------------------+
650| lineno | ``%(lineno)d`` | Source line number where the logging call was |
651| | | issued (if available). |
652+----------------+-------------------------+-----------------------------------------------+
653| module | ``%(module)s`` | Module (name portion of ``filename``). |
654+----------------+-------------------------+-----------------------------------------------+
655| msecs | ``%(msecs)d`` | Millisecond portion of the time when the |
656| | | :class:`LogRecord` was created. |
657+----------------+-------------------------+-----------------------------------------------+
658| message | ``%(message)s`` | The logged message, computed as ``msg % |
659| | | args``. This is set when |
660| | | :meth:`Formatter.format` is invoked. |
661+----------------+-------------------------+-----------------------------------------------+
662| msg | You shouldn't need to | The format string passed in the original |
663| | format this yourself. | logging call. Merged with ``args`` to |
664| | | produce ``message``, or an arbitrary object |
665| | | (see :ref:`arbitrary-object-messages`). |
666+----------------+-------------------------+-----------------------------------------------+
667| name | ``%(name)s`` | Name of the logger used to log the call. |
668+----------------+-------------------------+-----------------------------------------------+
669| pathname | ``%(pathname)s`` | Full pathname of the source file where the |
670| | | logging call was issued (if available). |
671+----------------+-------------------------+-----------------------------------------------+
672| process | ``%(process)d`` | Process ID (if available). |
673+----------------+-------------------------+-----------------------------------------------+
674| processName | ``%(processName)s`` | Process name (if available). |
675+----------------+-------------------------+-----------------------------------------------+
676| relativeCreated| ``%(relativeCreated)d`` | Time in milliseconds when the LogRecord was |
677| | | created, relative to the time the logging |
678| | | module was loaded. |
679+----------------+-------------------------+-----------------------------------------------+
680| thread | ``%(thread)d`` | Thread ID (if available). |
681+----------------+-------------------------+-----------------------------------------------+
682| threadName | ``%(threadName)s`` | Thread name (if available). |
683+----------------+-------------------------+-----------------------------------------------+
684
685.. versionchanged:: 2.5
686 *funcName* was added.
687
Vinay Sajipbee739b2012-07-20 09:48:46 +0100688.. versionchanged:: 2.6
689 *processName* was added.
690
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100691.. _logger-adapter:
692
693LoggerAdapter Objects
694---------------------
695
696:class:`LoggerAdapter` instances are used to conveniently pass contextual
Serhiy Storchaka610f84a2013-12-23 18:19:34 +0200697information into logging calls. For a usage example, see the section on
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100698:ref:`adding contextual information to your logging output <context-info>`.
699
700.. versionadded:: 2.6
701
702
703.. class:: LoggerAdapter(logger, extra)
704
705 Returns an instance of :class:`LoggerAdapter` initialized with an
706 underlying :class:`Logger` instance and a dict-like object.
707
708 .. method:: process(msg, kwargs)
709
710 Modifies the message and/or keyword arguments passed to a logging call in
711 order to insert contextual information. This implementation takes the object
712 passed as *extra* to the constructor and adds it to *kwargs* using key
713 'extra'. The return value is a (*msg*, *kwargs*) tuple which has the
714 (possibly modified) versions of the arguments passed in.
715
716In addition to the above, :class:`LoggerAdapter` supports the following
Vinay Sajip41e9b402013-10-31 01:08:59 +0000717methods of :class:`Logger`: :meth:`~Logger.debug`, :meth:`~Logger.info`,
718:meth:`~Logger.warning`, :meth:`~Logger.error`, :meth:`~Logger.exception`,
719:meth:`~Logger.critical`, :meth:`~Logger.log` and :meth:`~Logger.isEnabledFor`.
720These methods have the same signatures as their counterparts in :class:`Logger`,
721so you can use the two types of instances interchangeably for these calls.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100722
723.. versionchanged:: 2.7
Vinay Sajip41e9b402013-10-31 01:08:59 +0000724 The :meth:`~Logger.isEnabledFor` method was added to :class:`LoggerAdapter`.
725 This method delegates to the underlying logger.
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100726
727
728Thread Safety
729-------------
730
731The logging module is intended to be thread-safe without any special work
732needing to be done by its clients. It achieves this though using threading
733locks; there is one lock to serialize access to the module's shared data, and
734each handler also creates a lock to serialize access to its underlying I/O.
735
736If you are implementing asynchronous signal handlers using the :mod:`signal`
737module, you may not be able to use logging from within such handlers. This is
738because lock implementations in the :mod:`threading` module are not always
739re-entrant, and so cannot be invoked from such signal handlers.
740
Georg Brandl8ec7f652007-08-15 14:28:01 +0000741
Vinay Sajipb5902e62009-01-15 22:48:13 +0000742Module-Level Functions
743----------------------
744
Georg Brandl8ec7f652007-08-15 14:28:01 +0000745In addition to the classes described above, there are a number of module- level
746functions.
747
748
749.. function:: getLogger([name])
750
751 Return a logger with the specified name or, if no name is specified, return a
752 logger which is the root logger of the hierarchy. If specified, the name is
753 typically a dot-separated hierarchical name like *"a"*, *"a.b"* or *"a.b.c.d"*.
754 Choice of these names is entirely up to the developer who is using logging.
755
756 All calls to this function with a given name return the same logger instance.
757 This means that logger instances never need to be passed between different parts
758 of an application.
759
760
761.. function:: getLoggerClass()
762
763 Return either the standard :class:`Logger` class, or the last class passed to
764 :func:`setLoggerClass`. This function may be called from within a new class
Vinay Sajip6afafc72013-11-15 20:54:15 +0000765 definition, to ensure that installing a customized :class:`Logger` class will
766 not undo customizations already applied by other code. For example::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000767
768 class MyLogger(logging.getLoggerClass()):
769 # ... override behaviour here
770
771
772.. function:: debug(msg[, *args[, **kwargs]])
773
774 Logs a message with level :const:`DEBUG` on the root logger. The *msg* is the
775 message format string, and the *args* are the arguments which are merged into
776 *msg* using the string formatting operator. (Note that this means that you can
777 use keywords in the format string, together with a single dictionary argument.)
778
779 There are two keyword arguments in *kwargs* which are inspected: *exc_info*
780 which, if it does not evaluate as false, causes exception information to be
781 added to the logging message. If an exception tuple (in the format returned by
782 :func:`sys.exc_info`) is provided, it is used; otherwise, :func:`sys.exc_info`
783 is called to get the exception information.
784
785 The other optional keyword argument is *extra* which can be used to pass a
786 dictionary which is used to populate the __dict__ of the LogRecord created for
787 the logging event with user-defined attributes. These custom attributes can then
788 be used as you like. For example, they could be incorporated into logged
789 messages. For example::
790
791 FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
792 logging.basicConfig(format=FORMAT)
793 d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
794 logging.warning("Protocol problem: %s", "connection reset", extra=d)
795
Vinay Sajipfe08e6f2010-09-11 10:25:28 +0000796 would print something like::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000797
798 2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset
799
800 The keys in the dictionary passed in *extra* should not clash with the keys used
801 by the logging system. (See the :class:`Formatter` documentation for more
802 information on which keys are used by the logging system.)
803
804 If you choose to use these attributes in logged messages, you need to exercise
805 some care. In the above example, for instance, the :class:`Formatter` has been
806 set up with a format string which expects 'clientip' and 'user' in the attribute
807 dictionary of the LogRecord. If these are missing, the message will not be
808 logged because a string formatting exception will occur. So in this case, you
809 always need to pass the *extra* dictionary with these keys.
810
811 While this might be annoying, this feature is intended for use in specialized
812 circumstances, such as multi-threaded servers where the same code executes in
813 many contexts, and interesting conditions which arise are dependent on this
814 context (such as remote client IP address and authenticated user name, in the
815 above example). In such circumstances, it is likely that specialized
816 :class:`Formatter`\ s would be used with particular :class:`Handler`\ s.
817
818 .. versionchanged:: 2.5
819 *extra* was added.
820
821
822.. function:: info(msg[, *args[, **kwargs]])
823
824 Logs a message with level :const:`INFO` on the root logger. The arguments are
825 interpreted as for :func:`debug`.
826
827
828.. function:: warning(msg[, *args[, **kwargs]])
829
830 Logs a message with level :const:`WARNING` on the root logger. The arguments are
831 interpreted as for :func:`debug`.
832
833
834.. function:: error(msg[, *args[, **kwargs]])
835
836 Logs a message with level :const:`ERROR` on the root logger. The arguments are
837 interpreted as for :func:`debug`.
838
839
840.. function:: critical(msg[, *args[, **kwargs]])
841
842 Logs a message with level :const:`CRITICAL` on the root logger. The arguments
843 are interpreted as for :func:`debug`.
844
845
Vinay Sajip51f80c12014-04-15 23:11:15 +0100846.. function:: exception(msg[, *args[, **kwargs]])
Georg Brandl8ec7f652007-08-15 14:28:01 +0000847
848 Logs a message with level :const:`ERROR` on the root logger. The arguments are
Vinay Sajip6fcb9a52015-01-06 11:10:12 +0000849 interpreted as for :func:`debug`, except that any passed *exc_info* is not
850 inspected. Exception info is always added to the logging message. This
851 function should only be called from an exception handler.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000852
853
854.. function:: log(level, msg[, *args[, **kwargs]])
855
856 Logs a message with level *level* on the root logger. The other arguments are
857 interpreted as for :func:`debug`.
858
Vinay Sajipace08ab2014-01-15 13:27:58 +0000859 .. note:: The above module-level convenience functions, which delegate to the
860 root logger, call :func:`basicConfig` to ensure that at least one handler
861 is available. Because of this, they should *not* be used in threads,
862 in versions of Python earlier than 2.7.1 and 3.2, unless at least one
863 handler has been added to the root logger *before* the threads are
864 started. In earlier versions of Python, due to a thread safety shortcoming
865 in :func:`basicConfig`, this can (under rare circumstances) lead to
866 handlers being added multiple times to the root logger, which can in turn
867 lead to multiple messages for the same event.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000868
869.. function:: disable(lvl)
870
871 Provides an overriding level *lvl* for all loggers which takes precedence over
872 the logger's own level. When the need arises to temporarily throttle logging
Vinay Sajip2060e422010-03-17 15:05:57 +0000873 output down across the whole application, this function can be useful. Its
874 effect is to disable all logging calls of severity *lvl* and below, so that
875 if you call it with a value of INFO, then all INFO and DEBUG events would be
876 discarded, whereas those of severity WARNING and above would be processed
Vinay Sajipe9cb5e92013-11-30 22:43:13 +0000877 according to the logger's effective level. If
878 ``logging.disable(logging.NOTSET)`` is called, it effectively removes this
879 overriding level, so that logging output again depends on the effective
880 levels of individual loggers.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000881
882
883.. function:: addLevelName(lvl, levelName)
884
885 Associates level *lvl* with text *levelName* in an internal dictionary, which is
886 used to map numeric levels to a textual representation, for example when a
887 :class:`Formatter` formats a message. This function can also be used to define
888 your own levels. The only constraints are that all levels used must be
889 registered using this function, levels should be positive integers and they
890 should increase in increasing order of severity.
891
Vinay Sajip3a5fc4b2013-01-08 11:18:42 +0000892 .. note:: If you are thinking of defining your own levels, please see the
893 section on :ref:`custom-levels`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000894
895.. function:: getLevelName(lvl)
896
897 Returns the textual representation of logging level *lvl*. If the level is one
898 of the predefined levels :const:`CRITICAL`, :const:`ERROR`, :const:`WARNING`,
899 :const:`INFO` or :const:`DEBUG` then you get the corresponding string. If you
900 have associated levels with names using :func:`addLevelName` then the name you
901 have associated with *lvl* is returned. If a numeric value corresponding to one
902 of the defined levels is passed in, the corresponding string representation is
903 returned. Otherwise, the string "Level %s" % lvl is returned.
904
Vinay Sajipf40a4072014-09-18 17:46:58 +0100905 .. note:: Integer levels should be used when e.g. setting levels on instances
906 of :class:`Logger` and handlers. This function is used to convert between
907 an integer level and the level name displayed in the formatted log output
908 by means of the ``%(levelname)s`` format specifier (see
909 :ref:`logrecord-attributes`).
910
Georg Brandl8ec7f652007-08-15 14:28:01 +0000911
912.. function:: makeLogRecord(attrdict)
913
914 Creates and returns a new :class:`LogRecord` instance whose attributes are
915 defined by *attrdict*. This function is useful for taking a pickled
916 :class:`LogRecord` attribute dictionary, sent over a socket, and reconstituting
917 it as a :class:`LogRecord` instance at the receiving end.
918
919
920.. function:: basicConfig([**kwargs])
921
922 Does basic configuration for the logging system by creating a
923 :class:`StreamHandler` with a default :class:`Formatter` and adding it to the
Vinay Sajip1c77b7f2009-10-10 20:32:36 +0000924 root logger. The functions :func:`debug`, :func:`info`, :func:`warning`,
Georg Brandl8ec7f652007-08-15 14:28:01 +0000925 :func:`error` and :func:`critical` will call :func:`basicConfig` automatically
926 if no handlers are defined for the root logger.
927
Vinay Sajip1c77b7f2009-10-10 20:32:36 +0000928 This function does nothing if the root logger already has handlers
929 configured for it.
Georg Brandldfb5bbd2008-05-09 06:18:27 +0000930
Georg Brandl8ec7f652007-08-15 14:28:01 +0000931 .. versionchanged:: 2.4
932 Formerly, :func:`basicConfig` did not take any keyword arguments.
933
Vinay Sajip3a5fc4b2013-01-08 11:18:42 +0000934 .. note:: This function should be called from the main thread before other
935 threads are started. In versions of Python prior to 2.7.1 and 3.2, if
936 this function is called from multiple threads, it is possible (in rare
937 circumstances) that a handler will be added to the root logger more than
938 once, leading to unexpected results such as messages being duplicated in
939 the log.
Vinay Sajip89e1ae22010-09-17 10:09:04 +0000940
Georg Brandl8ec7f652007-08-15 14:28:01 +0000941 The following keyword arguments are supported.
942
Georg Brandl44ea77b2013-03-28 13:28:44 +0100943 .. tabularcolumns:: |l|L|
944
Georg Brandl8ec7f652007-08-15 14:28:01 +0000945 +--------------+---------------------------------------------+
946 | Format | Description |
947 +==============+=============================================+
948 | ``filename`` | Specifies that a FileHandler be created, |
949 | | using the specified filename, rather than a |
950 | | StreamHandler. |
951 +--------------+---------------------------------------------+
952 | ``filemode`` | Specifies the mode to open the file, if |
953 | | filename is specified (if filemode is |
954 | | unspecified, it defaults to 'a'). |
955 +--------------+---------------------------------------------+
956 | ``format`` | Use the specified format string for the |
957 | | handler. |
958 +--------------+---------------------------------------------+
959 | ``datefmt`` | Use the specified date/time format. |
960 +--------------+---------------------------------------------+
961 | ``level`` | Set the root logger level to the specified |
962 | | level. |
963 +--------------+---------------------------------------------+
964 | ``stream`` | Use the specified stream to initialize the |
965 | | StreamHandler. Note that this argument is |
966 | | incompatible with 'filename' - if both are |
967 | | present, 'stream' is ignored. |
968 +--------------+---------------------------------------------+
969
970
971.. function:: shutdown()
972
973 Informs the logging system to perform an orderly shutdown by flushing and
Vinay Sajip91f0ee42008-03-16 21:35:58 +0000974 closing all handlers. This should be called at application exit and no
975 further use of the logging system should be made after this call.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000976
977
978.. function:: setLoggerClass(klass)
979
980 Tells the logging system to use the class *klass* when instantiating a logger.
981 The class should define :meth:`__init__` such that only a name argument is
982 required, and the :meth:`__init__` should call :meth:`Logger.__init__`. This
983 function is typically called before any loggers are instantiated by applications
984 which need to use custom logger behavior.
985
986
Vinay Sajip61afd262010-02-19 23:53:17 +0000987Integration with the warnings module
988------------------------------------
989
990The :func:`captureWarnings` function can be used to integrate :mod:`logging`
991with the :mod:`warnings` module.
992
993.. function:: captureWarnings(capture)
994
995 This function is used to turn the capture of warnings by logging on and
996 off.
997
Vinay Sajip5dbca9c2011-04-08 11:40:38 +0100998 If *capture* is ``True``, warnings issued by the :mod:`warnings` module will
999 be redirected to the logging system. Specifically, a warning will be
Vinay Sajip61afd262010-02-19 23:53:17 +00001000 formatted using :func:`warnings.formatwarning` and the resulting string
Éric Araujoa318a3b2012-02-26 01:36:31 +01001001 logged to a logger named ``'py.warnings'`` with a severity of :const:`WARNING`.
Vinay Sajip61afd262010-02-19 23:53:17 +00001002
Georg Brandlf6d367452010-03-12 10:02:03 +00001003 If *capture* is ``False``, the redirection of warnings to the logging system
Vinay Sajip61afd262010-02-19 23:53:17 +00001004 will stop, and warnings will be redirected to their original destinations
Éric Araujoa318a3b2012-02-26 01:36:31 +01001005 (i.e. those in effect before ``captureWarnings(True)`` was called).
Vinay Sajip61afd262010-02-19 23:53:17 +00001006
Georg Brandl8ec7f652007-08-15 14:28:01 +00001007
Vinay Sajip5dbca9c2011-04-08 11:40:38 +01001008.. seealso::
Georg Brandl8ec7f652007-08-15 14:28:01 +00001009
Vinay Sajip5dbca9c2011-04-08 11:40:38 +01001010 Module :mod:`logging.config`
1011 Configuration API for the logging module.
Georg Brandl8ec7f652007-08-15 14:28:01 +00001012
Vinay Sajip5dbca9c2011-04-08 11:40:38 +01001013 Module :mod:`logging.handlers`
1014 Useful handlers included with the logging module.
Georg Brandl8ec7f652007-08-15 14:28:01 +00001015
Vinay Sajip5dbca9c2011-04-08 11:40:38 +01001016 :pep:`282` - A Logging System
1017 The proposal which described this feature for inclusion in the Python standard
1018 library.
Georg Brandl8ec7f652007-08-15 14:28:01 +00001019
Vinay Sajip5dbca9c2011-04-08 11:40:38 +01001020 `Original Python logging package <http://www.red-dove.com/python_logging.html>`_
1021 This is the original source for the :mod:`logging` package. The version of the
1022 package available from this site is suitable for use with Python 1.5.2, 2.1.x
1023 and 2.2.x, which do not include the :mod:`logging` package in the standard
1024 library.
Georg Brandlc37f2882007-12-04 17:46:27 +00001025