Logging question

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Sep 23 15:59:32 CEST 2009


On Sep 23, 2:46 pm, Jean-Michel Pichavant <jeanmic... at sequans.com>
wrote:
> I personally use the following pattern:
>
> In any submodule moduleA.py of an application:
>
> import MyApp
> _logger =logging.getLogger(MyApp.logger.name + '.moduleA') # attach my
> logger to MyApp logger

It's also common to use the pattern

logger = logging.getLogger(__name__)

which will use the name of the module for a logger name, correctly
getting the name of subpackages and submodules when used therein.

Regards,

Vinay Sajip



More information about the Python-list mailing list