我在 settings.py 文件中有我的 Django 日志定義,如下所示:LOG_DIR = '/var/log/myapp/'LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'standard': { 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s", 'datefmt' : "%d/%b/%Y %H:%M:%S" }, }, 'handlers': { 'null': { 'level':'DEBUG' if DEBUG else 'WARNING', 'class':'logging.NullHandler', }, 'logfile': { 'level':'DEBUG' if DEBUG else 'WARNING', 'class':'logging.handlers.RotatingFileHandler', 'filename': LOG_DIR + "/application.log", 'maxBytes': 1024 * 1024 * 10, #Max 10MB 'backupCount': 3, 'formatter': 'standard', }, 'console':{ 'level':'INFO', 'class':'logging.StreamHandler', 'formatter': 'standard' }, }, 'loggers': { 'django': { 'handlers':['console'], 'propagate': True, 'level':'WARN', }, 'django.db.backends': { 'handlers': ['console'], 'level': 'DEBUG' if DEBUG else 'WARNING', 'propagate': False, }, '': { 'handlers': ['console', 'logfile'], 'level': 'DEBUG', }, }}現在,我在這個項目中有幾個應用程序,我必須以一種簡單的方式組織它們的日志記錄,相互創建一個單獨的日志,我的意思是:項目一般日志My_App1 日志My_App2 日志My_App3 日志這可以通過 Django 以簡單的方式實現嗎?
Django:如何將每個應用程序記錄到一個單獨的文件中
慕工程0101907
2021-09-11 15:07:00