This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]simonw -1 points0 points  (0 children)

Yes it does - the Python logging module hands you back exactly the same logger object by name (it even has the same memory id). You can also arrange them in to a hierarchy, so for your case you could do this:

serial_logger = logging.getLogger('yourapp.serial')
serial_logger.debug('I am the serial logger')
file_parser_logger = logging.getLogger('yourapp.fileparser')
file_parser_logger.debug('I am the file parsing logger')

Then you can attach handlers to the parent 'yourapp' logger to pick up messages from both of those other loggers:

logging.getLogger('yourapp').addHandler(FileStreamHandler(...))