summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliangke <lokyse@163.com>2018-03-05 14:31:22 +0800
committerliangke <lokyse@163.com>2018-03-05 14:41:37 +0800
commit7a3e0ef783715080e57d9281d0844c438b589fdf (patch)
treed2b54ac578fad5c5aef44bf21333420da4a3c2f6
parentc1d77aefc384025f908494a2843000b7f41e8a4b (diff)
Update the log setting of VIO
Change-Id: I2efb581a4cbe238f03aa91437da7590c7a9ef2ac Issue-ID: MULTICLOUD-151 Signed-off-by: liangke <lokyse@163.com>
-rw-r--r--vio/requirements.txt3
-rwxr-xr-xvio/run.sh8
-rw-r--r--vio/vio/pub/config/log.yml26
-rw-r--r--vio/vio/settings.py38
4 files changed, 43 insertions, 32 deletions
diff --git a/vio/requirements.txt b/vio/requirements.txt
index 6cecedc..8d5a51c 100644
--- a/vio/requirements.txt
+++ b/vio/requirements.txt
@@ -20,3 +20,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
diff --git a/vio/run.sh b/vio/run.sh
index 0c767aa..168ce4d 100755
--- a/vio/run.sh
+++ b/vio/run.sh
@@ -23,8 +23,12 @@ sed -i "s/AAI_PASSWORD =.*/AAI_PASSWORD = \"${AAI_PASSWORD}\"/g" vio/pub/config/
nohup python manage.py runserver 0.0.0.0:9004 2>&1 &
-while [ ! -f logs/runtime_vio.log ]; do
+logDir="/var/log/onap/multicloiud/vio"
+if [ ! -x $logDir ]; then
+ mkdir -p $logDir
+fi
+while [ ! -f $logDir/vio.log ]; do
sleep 1
done
-tail -F logs/runtime_vio.log
+tail -F $logDir/vio.log
diff --git a/vio/vio/pub/config/log.yml b/vio/vio/pub/config/log.yml
new file mode 100644
index 0000000..82eb814
--- /dev/null
+++ b/vio/vio/pub/config/log.yml
@@ -0,0 +1,26 @@
+version: 1
+disable_existing_loggers: False
+
+loggers:
+ vio:
+ handlers: [vio_handler]
+ level: "DEBUG"
+ propagate: False
+handlers:
+ vio_handler:
+ level: "DEBUG"
+ class: "logging.handlers.RotatingFileHandler"
+ filename: "/var/log/onap/multicloud/vio/vio.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/vio/vio/settings.py b/vio/vio/settings.py
index c0a9209..e82b523 100644
--- a/vio/vio/settings.py
+++ b/vio/vio/settings.py
@@ -12,7 +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__)))
@@ -83,36 +85,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': {
- 'vio_handler': {
- 'level': 'DEBUG',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(BASE_DIR, 'logs/runtime_vio.log'),
- 'formatter': 'standard',
- 'maxBytes': 1024 * 1024 * 50,
- 'backupCount': 5,
- },
- },
- 'loggers': {
- 'vio': {
- 'handlers': ['vio_handler'],
- 'level': 'DEBUG',
- 'propagate': False
- },
- }
-}
+LOGGING_CONFIG = None
+# yaml configuration of logging
+LOGGING_FILE = os.path.join(BASE_DIR, 'vio/pub/config/log.yml')
+config.yamlConfig(filepath=LOGGING_FILE, watchDog=True)
+
if 'test' in sys.argv:
from vio.pub.config import config