diff options
author | liangke <lokyse@163.com> | 2018-03-05 17:04:16 +0800 |
---|---|---|
committer | liangke <lokyse@163.com> | 2018-03-05 17:04:42 +0800 |
commit | d346df79314344c238866e9df0fb4b44c92d03ba (patch) | |
tree | 941966c1137e5be8b2b92112a9bb4d5366c951d2 /multivimbroker | |
parent | e677a3c5218e7dc277c21d17784cdfb210e0a7f2 (diff) |
Update log setting of multivimbroker
Change-Id: I6d666ed07c5c28edc3337028c29c502d4fbeb3dd
Issue-ID: MULTICLOUD-151
Signed-off-by: liangke <lokyse@163.com>
Diffstat (limited to 'multivimbroker')
-rw-r--r-- | multivimbroker/multivimbroker/pub/config/log.yml | 26 | ||||
-rw-r--r-- | multivimbroker/multivimbroker/settings.py | 40 | ||||
-rw-r--r-- | multivimbroker/requirements.txt | 3 | ||||
-rwxr-xr-x | multivimbroker/run.sh | 9 |
4 files changed, 45 insertions, 33 deletions
diff --git a/multivimbroker/multivimbroker/pub/config/log.yml b/multivimbroker/multivimbroker/pub/config/log.yml new file mode 100644 index 0000000..12da69f --- /dev/null +++ b/multivimbroker/multivimbroker/pub/config/log.yml @@ -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 + + diff --git a/multivimbroker/multivimbroker/settings.py b/multivimbroker/multivimbroker/settings.py index 4c6b089..dca2dd6 100644 --- a/multivimbroker/multivimbroker/settings.py +++ b/multivimbroker/multivimbroker/settings.py @@ -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 diff --git a/multivimbroker/requirements.txt b/multivimbroker/requirements.txt index caf8687..1378612 100644 --- a/multivimbroker/requirements.txt +++ b/multivimbroker/requirements.txt @@ -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 diff --git a/multivimbroker/run.sh b/multivimbroker/run.sh index a59356e..35f2b9e 100755 --- a/multivimbroker/run.sh +++ b/multivimbroker/run.sh @@ -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 |