LoggingΒΆ

The logging section in the configuration file specifies how logging should work.

For now, only two important settings are discussed here. An example of a logging section:

accounts:
    Google Mail:
        address: imap.gmail.com
        username: john.doe@gmail.com
        password: _My_PaSswOrd_
        ssl: true
        folders:
            - [INBOX, {filter: rbl, org: bl.spamcop.net, action: delete}]

logging:
    version: 1
    formatters:
        default:
            format: '%(asctime)s:%(name)-32s:%(funcName)-16s:%(levelname)-8s: %(message)s'
    handlers:
        mailfilter:
            class: logging.handlers.RotatingFileHandler
            formatter: default
            # FILENAME:
            filename: _test/log
            backupCount: 4
            maxBytes: 4194304
    loggers:
        mailfilter:
            handlers: [mailfilter]
            # LOG LEVEL:
            level: INFO

The filename entry specifies the path of the log file. The level entry specifies the log level. Valid log levels are: DEBUG, INFO, WARNING, ERROR and CRITICAL.

Note

The logging section is the YAML equivalent of the dict to be supplied to the logging.config.dictConfig() function. For a complete explanation of the logging section, see the Logging facility for Python.