18.4. Logging Config Basic
filename- Specifies that aFileHandlerbe created, using the specified filename, rather than aStreamHandlerfilemode- If filename is specified, open the file in this mode. Defaults to'a'format- Use the specified format string for the handlerdatefmt- Use the specified date/time format, as accepted bytime.strftime()style- If format is specified, use this style for the format string. One of'%','{'or'$'for printf-style,str.format()orstring.Templaterespectively. Defaults to'%'level- Set the root logger level to the specified levelstream- Use the specified stream to initialize theStreamHandler. Note that this argument is incompatible withfilename- if both are present, aValueErroris raisedhandlers- If specified, this should be an iterable of already created handlers to add to the root logger. Any handlers which don't already have a formatter set will be assigned the default formatter created in this function. Note that this argument is incompatible withfilenameorstream- if both are present, aValueErroris raised
>>> import logging
>>>
>>> logging.basicConfig(
... level='DEBUG',
... datefmt='%Y-%m-%d %H:%M:%S',
... format='{asctime} {levelname} {message}',
... style='{',
... filename='/tmp/myfile.log',
... filemode='w',
... )