Remove dependency on onaplogging in ztedriver
[vfc/nfvo/driver/vnfm/svnfm.git] / zte / vmanager / driver / settings.py
index ddc2a86..a9e0d3d 100644 (file)
@@ -16,10 +16,9 @@ import os
 import sys
 import platform
 from logging import config
-from onaplogging import monkey
-monkey.patch_all()
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+import yaml
 
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
@@ -60,7 +59,6 @@ MIDDLEWARE_CLASSES = [
     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
-    'driver.middleware.LogContextMiddleware',
 ]
 
 ROOT_URLCONF = 'driver.urls'
@@ -148,9 +146,17 @@ if platform.system() == 'Windows' or 'test' in sys.argv:
         }}
 else:
     LOGGING_CONFIG = None
+
+    log_path = '/var/log/onap/vfc/ztevnfmdriver'
+    if not os.path.exists(log_path):
+        os.makedirs(log_path)
+
     # yaml configuration of logging
     LOGGING_FILE = os.path.join(BASE_DIR, 'driver/log.yml')
     config.yamlConfig(filepath=LOGGING_FILE, watchDog=True)
+    with open(file=LOGGING_FILE, mode='r', encoding="utf-8")as file:
+        logging_yaml = yaml.load(stream=file, Loader=yaml.FullLoader)
+    config.dictConfig(config=logging_yaml)
 
 
 if 'test' in sys.argv: