فهرست منبع

修改日志配置

locky 1 سال پیش
والد
کامیت
ad5720345a
4فایلهای تغییر یافته به همراه77 افزوده شده و 70 حذف شده
  1. 21 14
      Ansjer/cn_config/formal_settings.py
  2. 19 17
      Ansjer/cn_config/test_settings.py
  3. 20 14
      Ansjer/eur_config/formal_settings.py
  4. 17 25
      Ansjer/us_config/formal_settings.py

+ 21 - 14
Ansjer/cn_config/formal_settings.py

@@ -198,12 +198,12 @@ EMAIL_HOST_PASSWORD = 'cjk1234'  # 授权码
 EMAIL_SUBJECT_PREFIX = 'website'  # 为邮件标题的前缀,默认是'[django]'
 EMAIL_USE_TLS = True  # 开启安全链接
 DEFAULT_FROM_EMAIL = SERVER_EMAIL = EMAIL_HOST_USER  # 设置发件人
+
 LOGGING = {
     'version': 1,
     'disable_existing_loggers': True,
     'formatters': {
         'error_format': {
-            # 'format': '{"asctime":"%(asctime)s","thread":"%(threadName)s:%(thread)d","errorline":"%(lineno)d","errorlevel":"%(levelname)s","errorcontent":"%(message)s"}'
             'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
         },
         'standard': {
@@ -221,10 +221,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
-            'backupCount': 30,
-            'when': 'D',
+            'maxBytes': 1024 * 1024 * 5,  # 5 MB
+            'backupCount': 5,
             'formatter': 'error_format',
         },
         'console': {
@@ -234,10 +234,19 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
+        'error_code': {
+            'level': 'INFO',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/error_code/error_code.log',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
@@ -254,8 +263,6 @@ LOGGING = {
     'loggers': {
         'django': {
             'handlers': ['default', 'console'],
-            # 'handlers': ['mail_admins','default','console'],
-            # 'level': 'ERROR',
             'level': 'ERROR',
             'propagate': False
         },
@@ -265,15 +272,15 @@ LOGGING = {
             'level': 'INFO',
             'propagate': False
         },
+        'error_code': {
+            'handlers': ['error_code'],
+            'level': 'INFO',
+            'propagate': False
+        },
         'pay': {
             'handlers': ['pay'],
             'level': 'INFO',
             'propagate': False
         },
-        # 'django.db.backends': {
-        #     'handlers': ['console'],
-        #     'propagate': True,
-        #     'level': 'DEBUG',
-        # },
     }
 }

+ 19 - 17
Ansjer/cn_config/test_settings.py

@@ -19,6 +19,7 @@ INSTALLED_APPS = [
     'imagekit',
     'Model',
     'PushModel',
+    'django_apscheduler'
 ]
 
 MIDDLEWARE = [
@@ -74,15 +75,15 @@ WSGI_APPLICATION = 'Ansjer.cn_config.test_wsgi.application'
 
 # 业务数据库
 DATABASE_DATA = 'ansjer_server_test'
-SERVER_HOST = 'server-test.cvp7gfpnmziz.rds.cn-northwest-1.amazonaws.com.cn'
+SERVER_HOST = 'server-cn.cvp7gfpnmziz.rds.cn-northwest-1.amazonaws.com.cn'
 DATABASES_USER = 'aws_rds'
-DATABASES_PASS = 'tIPV7Dhvi8LDageBIrsI'
+DATABASES_PASS = 'H84NQ8NARr9e39tn6aW5'
 
 # 推送数据库
 DATABASE_DATA2 = 'ansjer_push_test'
-SERVER_HOST2 = 'push-test.cvp7gfpnmziz.rds.cn-northwest-1.amazonaws.com.cn'
+SERVER_HOST2 = 'push-cn.cvp7gfpnmziz.rds.cn-northwest-1.amazonaws.com.cn'
 DATABASES_USER2 = 'aws_rds'
-DATABASES_PASS2 = 'p7XolzlQoOJ2YqvBqogr'
+DATABASES_PASS2 = 'Dil02uKDyd5Mxv7fhhHJ'
 
 DATABASES = {
     'default': {
@@ -120,6 +121,7 @@ DATABASES = {
 DATABASE_ROUTERS = ['Ansjer.database_router.DatabaseAppsRouter']
 DATABASE_APPS_MAPPING = {
     'Model': 'default',
+    'django_apscheduler': 'default',
     'PushModel': 'mysql02',
 }
 
@@ -220,10 +222,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
-            'backupCount': 30,
-            'when': 'D',
+            'maxBytes': 1024 * 1024 * 5,  # 5 MB
+            'backupCount': 5,
             'formatter': 'error_format',
         },
         'console': {
@@ -233,19 +235,19 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
-        'device_info': {
+        'error_code': {
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
-            'filename': BASE_DIR + '/static/log/device_info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/error_code/error_code.log',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
@@ -271,8 +273,8 @@ LOGGING = {
             'level': 'INFO',
             'propagate': False
         },
-        'device_info': {
-            'handlers': ['device_info'],
+        'error_code': {
+            'handlers': ['error_code'],
             'level': 'INFO',
             'propagate': False
         },

+ 20 - 14
Ansjer/eur_config/formal_settings.py

@@ -201,7 +201,6 @@ LOGGING = {
     'disable_existing_loggers': True,
     'formatters': {
         'error_format': {
-            # 'format': '{"asctime":"%(asctime)s","thread":"%(threadName)s:%(thread)d","errorline":"%(lineno)d","errorlevel":"%(levelname)s","errorcontent":"%(message)s"}'
             'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
         },
         'standard': {
@@ -219,10 +218,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
-            'backupCount': 30,
-            'when': 'D',
+            'maxBytes': 1024 * 1024 * 5,  # 5 MB
+            'backupCount': 5,
             'formatter': 'error_format',
         },
         'console': {
@@ -232,10 +231,19 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
+        'error_code': {
+            'level': 'INFO',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/error_code/error_code.log',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
@@ -252,8 +260,6 @@ LOGGING = {
     'loggers': {
         'django': {
             'handlers': ['default', 'console'],
-            # 'handlers': ['mail_admins','default','console'],
-            # 'level': 'ERROR',
             'level': 'ERROR',
             'propagate': False
         },
@@ -263,15 +269,15 @@ LOGGING = {
             'level': 'INFO',
             'propagate': False
         },
+        'error_code': {
+            'handlers': ['error_code'],
+            'level': 'INFO',
+            'propagate': False
+        },
         'pay': {
             'handlers': ['pay'],
             'level': 'INFO',
             'propagate': False
         },
-        # 'django.db.backends': {
-        #     'handlers': ['console'],
-        #     'propagate': True,
-        #     'level': 'DEBUG',
-        # },
     }
 }

+ 17 - 25
Ansjer/us_config/formal_settings.py

@@ -204,7 +204,6 @@ LOGGING = {
     'disable_existing_loggers': True,
     'formatters': {
         'error_format': {
-            # 'format': '{"asctime":"%(asctime)s","thread":"%(threadName)s:%(thread)d","errorline":"%(lineno)d","errorlevel":"%(levelname)s","errorcontent":"%(message)s"}'
             'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
         },
         'standard': {
@@ -222,10 +221,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
-            'backupCount': 30,
-            'when': 'D',
+            'maxBytes': 1024 * 1024 * 5,  # 5 MB
+            'backupCount': 5,
             'formatter': 'error_format',
         },
         'console': {
@@ -235,19 +234,19 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
-        'device_info': {
+        'error_code': {
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
-            'filename': BASE_DIR + '/static/log/device_info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/error_code/error_code.log',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
@@ -264,31 +263,24 @@ LOGGING = {
     'loggers': {
         'django': {
             'handlers': ['default', 'console'],
-            # 'handlers': ['mail_admins','default','console'],
-            # 'level': 'ERROR',
             'level': 'ERROR',
             'propagate': False
         },
         # log 调用时需要当作参数传入
         'info': {
             'handlers': ['info'],
-            'level':'INFO',
+            'level': 'INFO',
             'propagate': False
         },
-        'device_info':{
-            'handlers': ['device_info'],
-            'level':'INFO',
+        'error_code': {
+            'handlers': ['error_code'],
+            'level': 'INFO',
             'propagate': False
         },
         'pay': {
             'handlers': ['pay'],
-            'level':'INFO',
+            'level': 'INFO',
             'propagate': False
         },
-        # 'django.db.backends': {
-        #     'handlers': ['console'],
-        #     'propagate': True,
-        #     'level': 'DEBUG',
-        # },
     }
-}
+}