Browse Source

修改日志配置

locky 1 year ago
parent
commit
96867ce42a

+ 15 - 3
AnsjerPush/cn_config/cn_formal_settings.py

@@ -171,7 +171,6 @@ LOGGING = {
     'disable_existing_loggers': True,
     'disable_existing_loggers': True,
     'formatters': {
     'formatters': {
         'error_format': {
         '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'
             'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
         },
         },
         'standard': {
         'standard': {
@@ -189,7 +188,7 @@ LOGGING = {
         'default': {
         'default': {
             'level': 'ERROR',
             'level': 'ERROR',
             'class': 'logging.handlers.RotatingFileHandler',
             'class': 'logging.handlers.RotatingFileHandler',
-            'filename': BASE_DIR + '/static/log/error.log',
+            'filename': BASE_DIR + '/static/log/error/error.log',
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
             'backupCount': 5,
             'backupCount': 5,
             'formatter': 'error_format',
             'formatter': 'error_format',
@@ -208,11 +207,19 @@ LOGGING = {
             'formatter': 'standard',
             'formatter': 'standard',
             'encoding': 'utf-8',
             'encoding': 'utf-8',
         },
         },
+        'time': {
+            'level': 'INFO',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/time/info.log',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
     },
     },
     'loggers': {
     'loggers': {
         'django': {
         'django': {
             'handlers': ['default', 'console'],
             'handlers': ['default', 'console'],
-            # 'handlers': ['mail_admins','default','console'],
             'level': 'ERROR',
             'level': 'ERROR',
             'propagate': False
             'propagate': False
         },
         },
@@ -221,6 +228,11 @@ LOGGING = {
             'handlers': ['info'],
             'handlers': ['info'],
             'level': 'INFO',
             'level': 'INFO',
             'propagate': False
             'propagate': False
+        },
+        'time': {
+            'handlers': ['time'],
+            'level': 'INFO',
+            'propagate': False
         }
         }
     }
     }
 }
 }

+ 6 - 7
AnsjerPush/eur_config/eur_formal_settings.py

@@ -194,20 +194,19 @@ LOGGING = {
         },
         },
         'info': {
         'info': {
             'level': 'INFO',
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'maxBytes': 1024 * 1024 * 300,  # 300M
-            'backupCount': 30,
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'formatter': 'standard',
             'encoding': 'utf-8',
             'encoding': 'utf-8',
         },
         },
         'time': {
         'time': {
             'level': 'INFO',
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/time/info.log',
             'filename': BASE_DIR + '/static/log/time/info.log',
-            'maxBytes': 1024 * 1024 * 300,  # 300M
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'formatter': 'standard',
             'encoding': 'utf-8',
             'encoding': 'utf-8',
         },
         },

+ 7 - 7
AnsjerPush/test_config/test_settings.py

@@ -199,19 +199,19 @@ LOGGING = {
         },
         },
         'info': {
         'info': {
             'level': 'INFO',
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'formatter': 'standard',
             'encoding': 'utf-8',
             'encoding': 'utf-8',
         },
         },
         'time': {
         'time': {
             'level': 'INFO',
             'level': 'INFO',
-            'class': 'logging.handlers.TimedRotatingFileHandler',
+            'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/time/info.log',
             'filename': BASE_DIR + '/static/log/time/info.log',
-            'backupCount': 30,
-            'when': 'D',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'formatter': 'standard',
             'encoding': 'utf-8',
             'encoding': 'utf-8',
         },
         },
@@ -220,7 +220,7 @@ LOGGING = {
         'django': {
         'django': {
             'handlers': ['default', 'console'],
             'handlers': ['default', 'console'],
             'level': 'ERROR',
             'level': 'ERROR',
-            'propagate': True
+            'propagate': False
         },
         },
         # log 调用时需要当作参数传入
         # log 调用时需要当作参数传入
         'info': {
         'info': {

+ 19 - 7
AnsjerPush/us_config/formal_settings.py

@@ -72,7 +72,7 @@ DATABASES = {
         'HOST': SERVER_HOST,
         'HOST': SERVER_HOST,
         'PORT': '3306',
         'PORT': '3306',
         'AUTOCOMMIT': True,
         'AUTOCOMMIT': True,
-        'CONN_MAX_AGE': 60,
+        'CONN_MAX_AGE': 1,
         'OPTIONS': {'charset': 'utf8mb4',
         'OPTIONS': {'charset': 'utf8mb4',
                     'use_unicode': True,
                     'use_unicode': True,
                     'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
                     'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
@@ -86,7 +86,7 @@ DATABASES = {
         'HOST': SERVER_HOST2,
         'HOST': SERVER_HOST2,
         'PORT': '3306',
         'PORT': '3306',
         'AUTOCOMMIT': True,
         'AUTOCOMMIT': True,
-        'CONN_MAX_AGE': 60,
+        'CONN_MAX_AGE': 1,
         'OPTIONS': {'charset': 'utf8mb4',
         'OPTIONS': {'charset': 'utf8mb4',
                     'use_unicode': True,
                     'use_unicode': True,
                     'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
                     'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
@@ -172,7 +172,6 @@ LOGGING = {
     'disable_existing_loggers': True,
     'disable_existing_loggers': True,
     'formatters': {
     'formatters': {
         'error_format': {
         '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'
             'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
         },
         },
         'standard': {
         'standard': {
@@ -190,7 +189,7 @@ LOGGING = {
         'default': {
         'default': {
             'level': 'ERROR',
             'level': 'ERROR',
             'class': 'logging.handlers.RotatingFileHandler',
             'class': 'logging.handlers.RotatingFileHandler',
-            'filename': BASE_DIR + '/static/log/error.log',
+            'filename': BASE_DIR + '/static/log/error/error.log',
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
             'backupCount': 5,
             'backupCount': 5,
             'formatter': 'error_format',
             'formatter': 'error_format',
@@ -204,8 +203,17 @@ LOGGING = {
             'level': 'INFO',
             'level': 'INFO',
             'class': 'logging.handlers.RotatingFileHandler',
             'class': 'logging.handlers.RotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'maxBytes': 1024 * 1024 * 300,  # 300M
-            'backupCount': 30,
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'formatter': 'standard',
+            'encoding': 'utf-8',
+        },
+        'time': {
+            'level': 'INFO',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': BASE_DIR + '/static/log/time/info.log',
+            'backupCount': 10,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
             'formatter': 'standard',
             'formatter': 'standard',
             'encoding': 'utf-8',
             'encoding': 'utf-8',
         },
         },
@@ -213,7 +221,6 @@ LOGGING = {
     'loggers': {
     'loggers': {
         'django': {
         'django': {
             'handlers': ['default', 'console'],
             'handlers': ['default', 'console'],
-            # 'handlers': ['mail_admins','default','console'],
             'level': 'ERROR',
             'level': 'ERROR',
             'propagate': False
             'propagate': False
         },
         },
@@ -222,6 +229,11 @@ LOGGING = {
             'handlers': ['info'],
             'handlers': ['info'],
             'level': 'INFO',
             'level': 'INFO',
             'propagate': False
             'propagate': False
+        },
+        'time': {
+            'handlers': ['time'],
+            'level': 'INFO',
+            'propagate': False
         }
         }
     }
     }
 }
 }