slider

还是菜鸟
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

display log information in terminal

Posted on 2013-03-27 20:35  slider  阅读(190)  评论(0编辑  收藏  举报

  offical website note:

# import the logging library

import logging

# Get an instance of a logger
logger = logging.getLogger(__name__)

def my_view(request, arg1, arg):
    ...
    if bad_mojo:
        # Log an error message
        logger.error('Something went wrong!')
  but it not display log info in terminal. i donit why. but i hear that use 'print' is simple.
def my_view(request, arg1, arg):
    ...
    if bad_mojo:
        # Log  error message
        print 'Something went wrong!'

  through my test, it works well.