(continued from previous page) When you run this, on the console you will see and in the file you will see something like As you can see, the DEBUG message only shows up in the file. The other messages are sent to both destinations. This example uses console and file handlers, but you can use any number and combination of handlers you choose. Here is an example of a module using the logging configuration server: (continues on next page) 6 import logging import logging.config import time import os # read initial config file logging.config.fileConfig('logging.conf ') # create and start listener on port 9999 t =logging.config.listen( 9999 ) t.start() logger=logging.getLogger('simpleExample ') 10-22 22:19 root INFO Jackdaws love my big sphinx of quartz. 10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 10-22 22:19 myapp.area1 INFO How quickly daft jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from 10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly. root : INFO Jackdaws love my big sphinx of quartz. myapp.area1 : INFO How quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly. console=logging.StreamHandler() console.setLevel(logging .INFO) # set a format which is simpler for console use formatter =logging.Formatter(' %(name)-12s : %(levelname)-8s %(message)s ') # tell the handler to use this format console.setFormatter(formatter) # add the handler to the root logger logging.getLogger('').addHandler(console) # Now, we can log to the root logger, or any other logger. First the root... logging.info('Jackdaws love my big sphinx of quartz. ') # Now, define a couple of other loggers which might represent areas in your # application: logger1=logging.getLogger('myapp.area1 ') logger2=logging.getLogger('myapp.area2 ') logger1 .debug( 'Quick zephyrs blow, vexing daft Jim. ') logger1 .info('How quickly daft jumping zebras vex. ') logger2 .warning( 'Jail zesty vixen who grabbed pay from quack. ') logger2 .error('The five boxing wizards jump quickly. ') 5 Configuration server example