Update log setting of multivimbroker 15/34015/1
authorliangke <lokyse@163.com>
Mon, 5 Mar 2018 09:04:16 +0000 (17:04 +0800)
committerliangke <lokyse@163.com>
Mon, 5 Mar 2018 09:04:42 +0000 (17:04 +0800)
Change-Id: I6d666ed07c5c28edc3337028c29c502d4fbeb3dd
Issue-ID: MULTICLOUD-151
Signed-off-by: liangke <lokyse@163.com>
multivimbroker/multivimbroker/pub/config/log.yml [new file with mode: 0644]
multivimbroker/multivimbroker/settings.py
multivimbroker/requirements.txt
multivimbroker/run.sh

diff --git a/multivimbroker/multivimbroker/pub/config/log.yml b/multivimbroker/multivimbroker/pub/config/log.yml
new file mode 100644 (file)
index 0000000..12da69f
--- /dev/null
@@ -0,0 +1,26 @@
+version: 1
+disable_existing_loggers: False
+
+loggers:
+    multivimbroker:
+      handlers: [multivimbroker_handler]
+      level: "DEBUG"
+      propagate: False
+handlers:
+    multivimbroker_handler:
+        level: "DEBUG"
+        class: "logging.handlers.RotatingFileHandler"
+        filename: "/var/log/onap/multicloud/multivimbroker/multivimbroker.log"
+        formatter: "mdcFormat"
+        maxBytes: 1024*1024*50
+        backupCount: 10
+formatters:
+    standard:
+        format: "%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s"
+    mdcFormat:
+        format: "%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:[%(mdc)s]: %(message)s"
+        mdcfmt: "{requestID}"
+        datefmt: "%Y-%m-%d %H:%M:%S"
+        (): onaplogging.mdcformatter.MDCFormatter
+
+
index 4c6b089..dca2dd6 100644 (file)
@@ -12,6 +12,9 @@
 
 import os
 import sys
+from logging import config
+from onaplogging import monkey
+monkey.patch_all()
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -84,37 +87,12 @@ TIME_ZONE = 'UTC'
 
 STATIC_URL = '/static/'
 
-LOGGING = {
-    'version': 1,
-    'disable_existing_loggers': True,
-    'formatters': {
-        'standard': {
-            'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] \
-            [%(levelname)s]:%(message)s',
-        },
-    },
-    'filters': {
-    },
-    'handlers': {
-        'multivimbroker_handler': {
-            'level': 'DEBUG',
-            'class': 'logging.handlers.RotatingFileHandler',
-            'filename': os.path.join(BASE_DIR,
-                                     'logs/runtime_multivimbroker.log'),
-            'formatter': 'standard',
-            'maxBytes': 1024 * 1024 * 50,
-            'backupCount': 5,
-        },
-    },
-
-    'loggers': {
-        'multivimbroker': {
-            'handlers': ['multivimbroker_handler'],
-            'level': 'DEBUG',
-            'propagate': False
-        },
-    }
-}
+
+LOGGING_CONFIG = None
+# yaml configuration of logging
+LOGGING_FILE = os.path.join(BASE_DIR, 'multivimbroker/pub/config/log.yml')
+config.yamlConfig(filepath=LOGGING_FILE, watchDog=True)
+
 
 if 'test' in sys.argv:
     from multivimbroker.pub.config import config
index caf8687..1378612 100644 (file)
@@ -22,3 +22,6 @@ django-nose>=1.4.0
 coverage==4.2
 mock==2.0.0
 unittest_xml_reporting==1.12.0
+
+# for onap logging
+onappylog>=1.0.5
\ No newline at end of file
index a59356e..35f2b9e 100755 (executable)
@@ -21,10 +21,15 @@ sed -i "s/AAI_SCHEMA_VERSION =.*/AAI_SCHEMA_VERSION = \"${AAI_SCHEMA_VERSION}\"/
 sed -i "s/AAI_USERNAME =.*/AAI_USERNAME = \"${AAI_USERNAME}\"/g" multivimbroker/pub/config/config.py
 sed -i "s/AAI_PASSWORD =.*/AAI_PASSWORD = \"${AAI_PASSWORD}\"/g" multivimbroker/pub/config/config.py
 
+logDir="/var/log/onap/multicloud/multivimbroker"
+if [ ! -x  $logDir  ]; then
+       mkdir -p $logDir
+fi
+
 nohup python manage.py runserver 0.0.0.0:9001 2>&1 &
 
-while [ ! -f logs/runtime_multivimbroker.log ]; do
+while [ ! -f $logDir/multivimbroker.log ]; do
     sleep 1
 done
 
-tail -F logs/runtime_multivimbroker.log
+tail -F  $logDir/multivimbroker.log

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use