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.1.1.1. 1. debug

1.1.1.1.1. Logger.debug()

1.1.1.2. 2. info

1.1.1.2.1. Logger.info()

1.1.1.3. 3. warning

1.1.1.3.1. Logger.warning()

1.1.1.4. 4. error

1.1.1.4.1. Logger.error()

1.1.1.4.2. Logger.exception()

1.1.1.5. 5. critical

1.1.1.5.1. Logger.critical()

1.1.2. Logger.setLevel()

1.1.2.1. Ref. Severity Levels

1.1.3. Logger.getLogger()

1.1.3.1. 1. Multiple calls with the SAME name will return a reference to the SAME logger object.

1.1.3.2. 2. No name provided, 'root' logger will be called.

1.1.3.3. 3. Loggers that are further down in the hierarchical list are children of loggers higher up in the list. E.g. foo, foo.bar and foo.bar.baz

1.1.3.4. 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.

6.1.1.1. New node