码迷,mamicode.com
首页 > 其他好文 > 详细

【Django】Django 如何使用 Django设置的日志?

时间:2016-10-15 14:03:50      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

代码:

from django.core.management.base import BaseCommand, CommandError
from django.db import models
#from placeholders import *
import os
import time
import logging
from django.utils.log import getLogger

#from file_protect.views import logger
#logger = logging.getLogger("file_protect.alarm_handler")
#logger = logging.getLogger("file_protect.views")
logger = getLogger(root)

class Command(BaseCommand):
    def handle(self, *args, **options):
        print hello, django!
        while(True):
            logger.info("hello, django")
            print hello, django!
            time.sleep(5)

 

参考资料:

http://www.th7.cn/Program/Python/201607/902253.shtml

https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

 

【Django】Django 如何使用 Django设置的日志?

标签:

原文地址:http://www.cnblogs.com/junneyang/p/5964193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!