title: Python Logging - dictConfig - logging destination for sub modules
body: <p>I have a python logging server, two test applications and one shared module (submod.py) I want both applications to be able to send log events to the server and have the server decide how to store them into separate log files. This is fairly easily until the shared module starts to log, I do not know how to allow the server to identify which program the sub module is sending log events for to store to the correct log file.</p>
  
  <p>My logging server is a slightly modified version of the code I found <a href="https://docs.python.org/2.4/lib/network-logging.html" rel="nofollow noreferrer">here</a></p>
  
  <p>I tried to modify it to use a dictionary logging configuration similar to the following:</p>
  
  <p><strong>test_log.conf</strong></p>
  
  <pre><code>"handlers": {
              "console": {
                  "class": "logging.StreamHandler",
                  "level": "DEBUG",
                  "formatter": "complex",
                  "stream": "ext://sys.stdout"
              },
              "test_01": {
                  "class": "logging.handlers.RotatingFileHandler",
                  "level": "INFO",
                  "formatter": "complex",
                  "filename": "test_01.log",
                  "mode": "a",
                  "backupCount": 5,
                  "encoding": "utf8"
              },
              "test_02": {
                  "class": "logging.handlers.RotatingFileHandler",
                  "level": "INFO",
                  "formatter": "complex",
                  "filename": "test_02.log",
                  "mode": "a",
                  "backupCount": 5,
                  "encoding": "utf8"
              },
              "file": {
                  "class": "logging.handlers.RotatingFileHandler",
                  "level": "INFO",
                  "formatter": "complex",
                  "filename": "root.log",
                  "mode": "a",
                  "backupCount": 5,
                  "encoding": "utf8"
              }
          },
          "loggers": {
              "root": {
                  "level": "INFO",
                  "handlers": ["console", "file"]
              },
              "test_01":{
                  "level": "INFO",
                  "handlers": ["console", "test_01"]
              },
              "test_02": {
                  "level": "INFO",
                  "handlers": ["console", "test_02"]
              }
          }
  </code></pre>
  
  <p><strong>test_01.py</strong></p>
  
  <pre><code>main_logger = logging.getLogger('')
  main_logger.setLevel(logging.DEBUG)
  
  socketHandler = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT)
  
  main_logger.addHandler(socketHandler)
  
  logging.info('Test 01 main program')
  
  a = submod.SubClass()
  </code></pre>
  
  <p><strong>test_02.py</strong></p>
  
  <pre><code>main_logger = logging.getLogger('')
  main_logger.setLevel(logging.DEBUG)
  
  socketHandler = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT)
  
  main_logger.addHandler(socketHandler)
  
  logging.info('Test 02 main program')
  
  a = submod.SubClass()
  </code></pre>
  
  <p><strong>submod.py</strong></p>
  
  <pre><code>class SubClass(object):
      def __init__(self):
          log = logging.getLogger()
          log.debug('Debug')
          log.info('Info')
          log.warn('Warning')
          log.error('Error')
          log.critical('Critical')
          print(__name__)
  </code></pre>
  
  <p>How can I have the logging server intelligently know where to log messages from submod.py when both test_01 and test_02 are calling it.</p>
  
  <p>I apologize for formatting and the confusing explanation, the problem has caused brain-damage at this point for me.</p>
  
  <p><strong>Edited:</strong>
  For clarity and re-wording a bad explanation.</p>