django - Defining python loggers for shared modules -
i have, hopefully, simple question on python/django logging.
i writing django app, calls modules shared other processes, jobs, scripts , possibly other apps in due course - example common calculations.
i have configured logging django app in settings.py , in main app modules (views.py, etc) logger via:
logger = logging.getlogger('exampleapp')
everything works expected.
however, when app calls modules in other packages shared not want have same logging.getlogger('exampleapp') call because other processes use module use incorrect logger config.
furthermore using
logging.getlogger(__name__)
means when call module django app, doesn't log correct file.
so question is, shared modules, there way logger use instance in 'parent caller', in other words django app or standalone server process, or script , on? or simple having pass logger instance classes defined in module (as param in constructor)?
hope makes sense.
thanks.
the way have got work, without passing around logger objects, change
logger = logging.getlogger('exampleapp')
in top level module
logger = logging.getlogger()
so gets root
logger. root logger format followed other modules.
Comments
Post a Comment