Python best practice in terms of logging

Best practice is to follow Python’s rules for software (de)composition – the module is the unit of Python software, not the class. Hence, the recommended approach is to use

logger = logging.getLogger(__name__)

in each module, and to configure logging (using basicConfig() or dictConfig()) from the main script.

Loggers are singletons – there is no point in passing them around or storing them in instances of your classes.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)