Missing logging output in Python

gabor.a.halasz at gmail.com gabor.a.halasz at gmail.com
Fri Mar 8 15:07:25 CET 2013


Hi,

I would like to enable loggin in my script using the logging module that comes with Python 2.7.3.

I have the following few lines setting up logging in my script, but for whatever reason  I don't seem to get any output to stdout  or to a file provided to the basicConfig method.

Any ideas?

# cinfiguring logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)8s %(message)s',
                    datefmt='%Y-%m-%d\t%H:%M:%s', filename=config["currentLoop"], filemode='a')
# define a Handler that writes INFO messages to sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# set format that is cleaber 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)



More information about the Python-list mailing list