The configuration file format understood by fileConfig is
based on ConfigParser functionality. The file must contain sections
called [loggers], [handlers] and [formatters]
which identify by name the entities of each type which are defined in
the file. For each such entity, there is a separate section which
identified how that entity is configured. Thus, for a logger named
log01 in the [loggers] section, the relevant
configuration details are held in a section
[logger_log01]. Similarly, a handler called hand01 in
the [handlers] section will have its configuration held in a
section called [handler_hand01], while a formatter called
form01 in the [formatters] section will have its
configuration specified in a section called
[formatter_form01]. The root logger configuration must be
specified in a section called [logger_root].
Examples of these sections in the file are given below.
The root logger must specify a level and a list of handlers. An
example of a root logger section is given below.
[logger_root]
level=NOTSET
handlers=hand01
The level entry can be one of DEBUG, INFO, WARNING,
ERROR, CRITICAL or NOTSET. For the root logger only,
NOTSET means that all messages will be logged. Level values are
eval()uated in the context of the logging package's
namespace.
The handlers entry is a comma-separated list of handler names,
which must appear in the [handlers] section. These names must
appear in the [handlers] section and have corresponding
sections in the configuration file.
For loggers other than the root logger, some additional information is
required. This is illustrated by the following example.
The level and handlers entries are interpreted as for
the root logger, except that if a non-root logger's level is specified
as NOTSET, the system consults loggers higher up the hierarchy
to determine the effective level of the logger. The propagate
entry is set to 1 to indicate that messages must propagate to handlers
higher up the logger hierarchy from this logger, or 0 to indicate that
messages are not propagated to handlers up the hierarchy. The
qualname entry is the hierarchical channel name of the logger,
for example, the name used by the application to get the logger.
Sections which specify handler configuration are exemplified by the
following.
The class entry indicates the handler's class (as determined by
eval() in the logging package's namespace). The
level is interpreted as for loggers, and NOTSET is taken
to mean "log everything".
The formatter entry indicates the key name of the formatter for
this handler. If blank, a default formatter
(logging._defaultFormatter) is used. If a name is specified, it
must appear in the [formatters] section and have a
corresponding section in the configuration file.
The args entry, when eval()uated in the context of
the logging package's namespace, is the list of arguments to
the constructor for the handler class. Refer to the constructors for
the relevant handlers, or to the examples below, to see how typical
entries are constructed.
The format entry is the overall format string, and the
datefmt entry is the strftime()-compatible date/time format
string. If empty, the package substitutes ISO8601 format date/times, which
is almost equivalent to specifying the date format string "The ISO8601 format also specifies milliseconds, which are appended to the
result of using the above format string, with a comma separator. An example
time in ISO8601 format is 2003-01-23 00:29:50,411.