Python Logging

Organize and structure your thoughts to write an essay

Get Started. It's Free
or sign up with your email address
Rocket clouds
Python Logging by Mind Map: Python Logging

1. Logger

1.1. How to Log

1.1.1. Severity Levels 1. debug Logger.debug() 2. info 3. warning Logger.warning() 4. error Logger.error() Logger.exception() 5. critical Logger.critical()

1.1.2. Logger.setLevel() Ref. Severity Levels

1.1.3. Logger.getLogger() 1. Multiple calls with the SAME name will return a reference to the SAME logger object. 2. No name provided, 'root' logger will be called. 3. Loggers that are further down in the hierarchical list are children of loggers higher up in the list. E.g. foo, and 4. If a logger has not been set with a effective level, its parent effective level will be used instead. Child loggers can propagate messages up to the handers with their ancestor loggers, so that it is sufficient to configure handlers for a top-level logger and create child loggers as needed.

1.2. Log to Where

1.2.1. Logger.addHandler()

1.3. Which to Log

1.3.1. Logger.addFilter()

2. Handler

2.1. setFormatter()

2.2. addFilter() / removeFilter()

3. Formatter

3.1. format: %(<dictionary key>)s, e.g. '%(asctime)s - %(levelname)s - %(message)s'

4. Filter

5. How to configure logging

5.1. 1. Creating loggers, handlers, and formatters explicitly using python code.

5.2. 2. creating a logging config file and reading it using the fileConfig() function

5.3. 3. Creating a dictionary of configuration information and passing it to the dictConfig() function.

6. misc

6.1. Configuring logging for a Library

6.1.1. add 'NullHandler()' to prevent the log messages coming out of the library. BUT DON'T add other handlers in a library, as it will interfere the management of logging in applications. New node