Python logging module on Eclipse
Where should I see the logging outp开发者_运维技巧ut on Eclipse while debugging ? and when running ?
It will depends on how you configure your logging system. If you use only print statement, it should be shown in the console
view of eclipse.
If you use logging
and you configured a Console handler it should also be displayed in the console
eclipse view.
If you configured only file handler in the logging configuration, you'll have to tail the log files ;)
Here an example that worked for me:
# LOG
log = logging.getLogger("appname")
log.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(fmt)
log.addHandler(ch)
log.debug("something happened") # Will print on console '2013-01-26 12:58:28,974 - appname - DEBUG - something happened'
精彩评论