ID EN
Logging

Logger

Python 3.11

Syntax

PYTHON
class logging.Logger

Examples

Example 1
PYTHON
Stack (most recent call last):
Example 2
PYTHON
FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s'
logging.basicConfig(format=FORMAT)
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
logger = logging.getLogger('tcpserver')
logger.warning('Protocol problem: %s', 'connection reset', extra=d)
Example 3
PYTHON
2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset

See Also

getLogger() setLevel() setLevel() addHandler() removeHandler() NOTSET WARNING Logging Levels