raise ValueError('Invalid log level: %s' % loglevel)
logging.basicConfig(level=numeric_level, ...)
-The call to :func:`basicConfig` should come *before* any calls to :func:`debug`,
-:func:`info` etc. As it's intended as a one-off simple configuration facility,
-only the first call will actually do anything: subsequent calls are effectively
-no-ops.
+The call to :func:`basicConfig` should come *before* any calls to
+:func:`debug`, :func:`info`, etc. Otherwise, those functions will call
+:func:`basicConfig` for you with the default options. As it's intended as a
+one-off simple configuration facility, only the first call will actually do
+anything: subsequent calls are effectively no-ops.
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,
above example). In such circumstances, it is likely that specialized
:class:`Formatter`\ s would be used with particular :class:`Handler`\ s.
+ If no handler is attached to this logger (or any of its ancestors,
+ taking into account the relevant :attr:`Logger.propagate` attributes),
+ the message will be sent to the handler set on :attr:`lastResort`.
+
.. versionchanged:: 3.2
The *stack_info* parameter was added.
above example). In such circumstances, it is likely that specialized
:class:`Formatter`\ s would be used with particular :class:`Handler`\ s.
+ This function (as well as :func:`info`, :func:`warning`, :func:`error` and
+ :func:`critical`) will call :func:`basicConfig` if the root logger doesn't
+ have any handler attached.
+
.. versionchanged:: 3.2
The *stack_info* parameter was added.