I want to write django log to different, especially I want to log daily log file, such as 2015-11-09-log.txt 2015-11-10-log.txt, this is my settings.py file:
TODAY_STRING = datetime.datetime.now().strftime("%F") TODAY_LOG_DIR = os.path.dirname(__file__) + "/log/" + TODAY_STRING # TODAY_LOG_DIR = "/log/" + TODAY_STRING print "*******" print SITE_SRC_ROOT print TODAY_LOG_DIR print os.path.join(SITE_SRC_ROOT, TODAY_LOG_DIR, "todaytotal.log") print os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "todaytotal.log"), if os.path.exists(TODAY_LOG_DIR): pass else: os.mkdir(TODAY_LOG_DIR) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s: %(asctime)s %(module)s %(process)d %(thread)d %(message)s %(filename)s:%(funcName)s:%(lineno)d' } }, 'handlers': { 'total': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log", "total.txt"), }, 'todaytotal': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "todaytotal.txt"), }, 'dengbin': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 'dengbin.txt'), }, 'haiyang': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 'haiyang.txt'), }, 'meibo': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, "meibo.txt"), }, 'xiecheng': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 'xiecheng.txt'), }, 'tolerious': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'verbose', 'filename': os.path.join(SITE_SRC_ROOT, "log/" + TODAY_STRING, 'tolerious.txt'), } }, 'loggers': { 'xiecheng': { 'handlers': ['xiecheng', 'todaytotal', 'meibo', 'total'], 'propagate': False, 'level': 'DEBUG', }, 'dengbin': { 'handlers': ['dengbin', 'todaytotal', 'meibo', 'total'], 'propagate': False, 'level': 'DEBUG', }, 'haiyang': { 'handlers': ['haiyang', 'todaytotal', 'meibo', 'total'], 'propagate': False, 'level': 'DEBUG', }, 'tolerious': { 'handlers': ['tolerious', 'todaytotal', 'meibo', 'total'], 'propagate': False, 'level': 'DEBUG', } }, 'root': { 'handlers': ['total'], 'level': 'DEBUG', }, } but this doesn't work, it only log 2015-11-09-log.txt, when today is 2015-11-10, 2015-11-10-log.txt not generated. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0ca4d5be-88de-4e2e-afee-1c3b65bc3132%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.