标签:
代码:
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